diff --git a/classes/Window.js b/classes/Window.js index 2c4e75a..a30eda3 100644 --- a/classes/Window.js +++ b/classes/Window.js @@ -109,7 +109,7 @@ var Window = { } function loadDefaultInputWindows() { - var inputTypes = ['int', 'unknown']; + var inputTypes = ['int', 'singleChoice', 'unknown']; inputTypes.forEach((type) => { var inputName = 'input' + (type[0].toUpperCase()) + type.substr(1); diff --git a/enum/AIBuffer.js b/enum/AIBuffer.js new file mode 100644 index 0000000..17868cd --- /dev/null +++ b/enum/AIBuffer.js @@ -0,0 +1,7 @@ +module.exports = { + None: '_', + Factory: 'factory', + General: 'buffer', + Hall: 'townhall', + Resource: 'resource' +} diff --git a/enum/ArmorType.js b/enum/ArmorType.js new file mode 100644 index 0000000..5e4889b --- /dev/null +++ b/enum/ArmorType.js @@ -0,0 +1,8 @@ +// NOTE: oddly, the raw values here are still capitalized +module.exports = { + Ethereal: 'Ethereal', + Flesh: 'Flesh', + Metal: 'Metal', + Stone: 'Stone', + Wood: 'Wood' +} diff --git a/enum/AttackType.js b/enum/AttackType.js new file mode 100644 index 0000000..177a121 --- /dev/null +++ b/enum/AttackType.js @@ -0,0 +1,10 @@ +module.exports = { + None: 'unknown', + Normal: 'normal', + Pierce: 'pierce', + Siege: 'siege', + Spells: 'spells', + Chaos: 'chaos', + Magic: 'magic', + Hero: 'hero', +} diff --git a/enum/AttributeType.js b/enum/AttributeType.js new file mode 100644 index 0000000..ffcf820 --- /dev/null +++ b/enum/AttributeType.js @@ -0,0 +1,5 @@ +module.exports = { + Strength: 'STR', + Agility: 'AGI', + Intelligence: 'INT' +} diff --git a/enum/DefenseType.js b/enum/DefenseType.js new file mode 100644 index 0000000..c706538 --- /dev/null +++ b/enum/DefenseType.js @@ -0,0 +1,10 @@ +module.exports = { + Normal: 'normal', + Small: 'small', + Medium: 'medium', + Large: 'large', + Fortified: 'fort', + Hero: 'hero', + Divine: 'divine', + Unarmored: 'none' +} diff --git a/enum/MovementType.js b/enum/MovementType.js new file mode 100644 index 0000000..816ecf8 --- /dev/null +++ b/enum/MovementType.js @@ -0,0 +1,9 @@ +module.exports = { + None: '', + Foot: 'foot', + Horse: 'horse', + Fly: 'fly', + Hover: 'hover', + Float: 'float', + Amphibious: 'amph' +} diff --git a/enum/TeamColor.js b/enum/TeamColor.js new file mode 100644 index 0000000..0576937 --- /dev/null +++ b/enum/TeamColor.js @@ -0,0 +1,16 @@ +module.exports = { + OwningPlayer: -1, + Player1: 0, + Player2: 1, + Player3: 2, + Player4: 3, + Player5: 4, + Player6: 5, + Player7: 6, + Player8: 7, + Player9: 8, + Player10: 9, + Player11: 10, + Player12: 11, + NeutralHostile: 12 +} diff --git a/enum/UnitRace.js b/enum/UnitRace.js new file mode 100644 index 0000000..05f311d --- /dev/null +++ b/enum/UnitRace.js @@ -0,0 +1,13 @@ +module.exports = { + None: 'unknown', + Commoner: 'commoner', + Creep: 'creeps', + Critter: 'critters', + Demon: 'demon', + Human: 'human', + Naga: 'naga', + NightElf: 'nightelf', + Orc: 'orc', + Other: 'other', + Undead: 'undead' +} diff --git a/enum/WeaponType.js b/enum/WeaponType.js new file mode 100644 index 0000000..d4c16ee --- /dev/null +++ b/enum/WeaponType.js @@ -0,0 +1,11 @@ +module.exports = { + None: '', + Normal: 'normal', + Instant: 'instant', + Artillery: 'artillery', + ArtilleryLine: 'aline', + Missile: 'missile', + MissileSplash: 'msplash', + MissileBounce: 'mbounce', + MissileLine: 'mline' +} diff --git a/views/input/singleChoice.html b/views/input/singleChoice.html new file mode 100644 index 0000000..c367558 --- /dev/null +++ b/views/input/singleChoice.html @@ -0,0 +1,51 @@ + + + + + Ice Sickle - {{type}} + + + + + + + + +
+
+ Edit Value{{#if fieldName}} - {{fieldName}}{{/if}} + + + +
+ Cancel + OK +
+ + {{#if tooltip}} +

{{tooltip}}

+ {{/if}} +
+
+ + diff --git a/views/object-editor.html b/views/object-editor.html index 1f6d551..ce0faca 100644 --- a/views/object-editor.html +++ b/views/object-editor.html @@ -42,9 +42,47 @@ }) var userInputListener = false; + + // Stores field whose selection mode is a simple dropdown menu + // where only one option may be selected; value is the enum file + var userInputSingleChoices = { + // fieldType: enumeration file name + 'armorType': 'ArmorType', + 'attackType': 'AttackType', + 'weaponType': 'WeaponType', + 'moveType': 'MovementType', + 'teamColor': 'TeamColor', + 'defenseType': 'DefenseType', + 'attributeType': 'AttributeType', + 'unitRace': 'UnitRace', + 'aiBuffer': 'AIBuffer' + }; function requestUserInput(type, context, entryId, cb) { context.entryId = entryId; + // Is the input a single dropdown menu? + var singleChoice = userInputSingleChoices[type]; + if(singleChoice) { + type = 'singleChoice'; + + var dataChoices = require('../enum/' + singleChoice), + choices = Object.keys(dataChoices).map((key) => { + return { + key: key, + value: dataChoices[key], + selected: + // Sometimes the enums have integer values, so we must check if they are integers + // to avoid an error when trying to call toLowerCase() on them + ((typeof dataChoices[key] == 'string') ? dataChoices[key].toLowerCase() : dataChoices[key]) + == + ((typeof context.currentValue == 'string') ? context.currentValue.toLowerCase() : context.currentValue) + } + }); + + context['choices'] = choices; + } + + ipcRenderer.send('request-user-input', { type: type, context: context