New basic GUI designed roughly off of AoE3 - ALPHA 1

Features:
-Basic menu and settings dialog
-New look for panel
-Multiple unit selections are now visible in GUI

This was SVN commit r7635.
This commit is contained in:
WhiteTreePaladin
2010-06-26 18:10:03 +00:00
parent f1d23f203e
commit 786bd5d11a
6 changed files with 1363 additions and 766 deletions
@@ -227,9 +227,43 @@ function handleInputBeforeGui(ev)
bandbox.hidden = true;
var ents = Engine.PickFriendlyEntitiesInRect(x0, y0, x1, y1, Engine.GetPlayerID());
// Remove non-unit entities from the bandboxed selection (Probably should make buildings work somehow)
for (var i = ents.length-1; i >= 0; i--)
{
var template = Engine.GuiInterfaceCall("GetEntityState", ents[i]).template;
var firstWord = template.substring(0, template.search("/"));
if (firstWord != "units")
ents.splice(i, 1);
}
// Set selection list
g_Selection.setHighlightList([]);
g_Selection.reset();
g_Selection.addList(ents);
// Make selection groups
var j = 0;
for (var i = 0; i < ents.length; i++)
{
var template = Engine.GuiInterfaceCall("GetEntityState", ents[i]).template;
if (!g_Selection.groups.groupTypeCount[template])
{
g_Selection.groups.groupTypeCount[template] = 1;
g_Selection.groups.firstOfType[template] = i;
g_Selection.groups.groupTemplates.push(template);
g_Selection.groups.groupNumbers[template] = j;
j++;
}
else if (g_Selection.groups.groupTypeCount[template])
{
g_Selection.groups.groupTypeCount[template] += 1;
}
}
// turn on unit highlight for first unit in selection
getGUIObjectByName("unitSelectionHighlight[0]").hidden = false;
inputState = INPUT_NORMAL;
return true;
@@ -237,7 +271,6 @@ function handleInputBeforeGui(ev)
else if (ev.button == SDL_BUTTON_RIGHT)
{
// Cancel selection
var bandbox = getGUIObjectByName("bandbox");
bandbox.hidden = true;
@@ -563,6 +596,18 @@ function getTrainingQueueBatchStatus(entity, trainEntType)
// Called by GUI when user clicks production queue item
function removeFromTrainingQueue(entity, id)
{
Engine.PostNetworkCommand({"type": "stop-train", "entity": entity, "id": id});
console.write("removeFromTrainingQueue(entity = " + entity + ", id = " + id +")");
//Engine.PostNetworkCommand({"type": "stop-train", "entity": entity, "id": id});
}
function changePrimarySelectionGroup(entType)
{
getGUIObjectByName("unitSelectionHighlight[" + g_Selection.groups.primary + "]").hidden = true;
// set primary group
g_Selection.groups.primary = g_Selection.groups.groupNumbers[entType];
getGUIObjectByName("unitSelectionHighlight[" + g_Selection.groups.primary + "]").hidden = false;
// set primary selection
g_Selection.setPrimary(g_Selection.groups.firstOfType[entType]);
}
@@ -14,19 +14,68 @@ function _setMotionOverlay(ents, enabled)
Engine.GuiInterfaceCall("SetMotionDebugOverlay", { "entities":ents, "enabled":enabled });
}
//-------------------------------- -------------------------------- --------------------------------
// EntityGroups class for ordering / managing entities by their templates
//-------------------------------- -------------------------------- --------------------------------
function EntityGroups()
{
this.primary = 0;
this.groupNumbers = {};
this.firstOfType = {}; // array for holding index to first appearance of a specific unit type in g_Selection
this.groupTypeCount = {}; // format { name:count, name:count, ... } - maps units to the currently selected quantity of that type
this.groupTemplates = [];
}
EntityGroups.prototype.reset = function()
{
getGUIObjectByName("unitSelectionHighlight[" + g_Selection.groups.primary + "]").hidden = true;
this.primary = 0;
this.groupNumbers = {};
this.firstOfType = {};
this.groupTypeCount = {};
this.groupTemplates = [];
};
//-------------------------------- -------------------------------- --------------------------------
// EntitySelection class for managing the entity selection list and the primary selection
//-------------------------------- -------------------------------- --------------------------------
function EntitySelection()
{
// Private properties:
//--------------------------------
this.primary = 0; // The active selection in the unit details panel
this.selected = {}; // { id:id, id:id, ... } for each selected entity ID 'id'
this.highlighted = {}; // { id:id, ... } for mouseover-highlighted entity IDs
// (in these, the key is a string and the value is an int; we want to use the
// int form wherever possible since it's more efficient to send to the simulation code)
// { id:id, ... } for mouseover-highlighted entity IDs in these, the key is a string and the value is an int;
// we want to use the int form wherever possible since it's more efficient to send to the simulation code)
this.highlighted = {};
this.motionDebugOverlay = false;
// Public properties:
//--------------------------------
this.groups = new EntityGroups(); // the selection entity groups must be reset whenever the selection changes
this.dirty = false; // set whenever the selection has changed
}
EntitySelection.prototype.getPrimary = function()
{
return this.primary;
};
EntitySelection.prototype.setPrimary = function(index)
{
if (g_Selection.toList().length > index)
this.primary = index;
else
console.write("\"index\" is larger than g_Selection.toList().length: Cannot set Primary Selection.");
};
EntitySelection.prototype.resetPrimary = function()
{
this.primary = 0; // the primary selection must be reset whenever the selection changes
};
EntitySelection.prototype.toggle = function(ent)
{
if (this.selected[ent])
@@ -65,6 +114,8 @@ EntitySelection.prototype.reset = function()
_setHighlight(this.toList(), g_InactiveSelectionColour);
_setMotionOverlay(this.toList(), false);
this.selected = {};
this.resetPrimary();
this.groups.reset();
this.dirty = true;
};
@@ -1,315 +1,578 @@
// Cache dev-mode settings that are frequently or widely used
var g_DevSettings = {
controlAll: false
};
function init(initData, hotloadData)
{
if (hotloadData)
{
g_Selection.selected = hotloadData.selection;
}
else
{
// Starting for the first time:
startMusic();
}
onSimulationUpdate();
}
function leaveGame()
{
stopMusic();
endGame();
Engine.SwitchGuiPage("page_pregame.xml");
}
// Return some data that we'll use when hotloading this file after changes
function getHotloadData()
{
return { selection: g_Selection.selected };
}
function onTick()
{
g_DevSettings.controlAll = getGUIObjectByName("devControlAll").checked;
// TODO: at some point this controlAll needs to disable the simulation code's
// player checks (once it has some player checks)
updateCursor();
// If the selection changed, we need to regenerate the sim display
if (g_Selection.dirty)
onSimulationUpdate();
}
function onSimulationUpdate()
{
g_Selection.dirty = false;
var simState = Engine.GuiInterfaceCall("GetSimulationState");
// If we're called during init when the game is first loading, there will be
// no simulation yet, so do nothing
if (!simState)
return;
updateDebug(simState);
updatePlayerDisplay(simState);
updateUnitDisplay();
}
function updateDebug(simState)
{
var debug = getGUIObjectByName("debug");
if (getGUIObjectByName("devDisplayState").checked)
{
debug.hidden = false;
}
else
{
debug.hidden = true;
return;
}
var text = uneval(simState);
var selection = g_Selection.toList();
if (selection.length)
{
var entState = Engine.GuiInterfaceCall("GetEntityState", selection[0]);
if (entState)
{
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
text += "\n\n" + uneval(entState) + "\n\n" + uneval(template);
}
}
debug.caption = text;
}
function updatePlayerDisplay(simState)
{
var playerState = simState.players[Engine.GetPlayerID()];
getGUIObjectByName("resourceFood").caption = playerState.resourceCounts.food;
getGUIObjectByName("resourceWood").caption = playerState.resourceCounts.wood;
getGUIObjectByName("resourceStone").caption = playerState.resourceCounts.stone;
getGUIObjectByName("resourceMetal").caption = playerState.resourceCounts.metal;
getGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
}
function damageTypesToText(dmg)
{
if (!dmg)
return "(None)";
return dmg.hack + " Hack\n" + dmg.pierce + " Pierce\n" + dmg.crush + " Crush";
}
// The number of currently visible buttons (used to optimise showing/hiding)
var g_unitPanelButtons = { "Construction": 0, "Training": 0, "Queue": 0 };
// The unitSomethingPanel objects, which are displayed in a stack at the bottom of the screen,
// ordered with *lowest* first
var g_unitPanels = ["Stance", "Formation", "Construction", "Research", "Training", "Queue"];
// Helper function for updateUnitDisplay
function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
{
usedPanels[guiName] = 1;
var i = 0;
for each (var item in items)
{
var entType;
if (guiName == "Queue")
entType = item.template;
else
entType = item;
var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]");
var icon = getGUIObjectByName("unit"+guiName+"Icon["+i+"]");
var template = Engine.GuiInterfaceCall("GetTemplateData", entType);
if (!template)
continue; // ignore attempts to use invalid templates (an error should have been reported already)
var name;
if (template.name.specific && template.name.generic)
name = template.name.specific + " (" + template.name.generic + ")";
else
name = template.name.specific || template.name.generic || "???";
var tooltip;
if (guiName == "Queue")
{
var progress = Math.round(item.progress*100) + "%";
tooltip = name + " - " + progress;
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (item.count > 1 ? item.count : "");
getGUIObjectByName("unit"+guiName+"Progress["+i+"]").caption = (item.progress ? progress : "");
}
else
{
tooltip = "[font=\"serif-bold-16\"]" + name + "[/font]";
if (template.cost)
{
var font1 = "[font=\"serif-bold-13\"]";
var costs = [];
if (template.cost.food) costs.push(font1 + "Food:[/font] " + template.cost.food);
if (template.cost.wood) costs.push(font1 + "Wood:[/font] " + template.cost.wood);
if (template.cost.metal) costs.push(font1 + "Metal:[/font] " + template.cost.metal);
if (template.cost.stone) costs.push(font1 + "Stone:[/font] " + template.cost.stone);
if (costs.length)
tooltip += "\n" + costs.join(", ");
}
if (guiName == "Training")
{
var font1 = "[font=\"serif-13\"]";
var font2 = "[font=\"serif-bold-13\"]";
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
tooltip += "\n" + font1;
if (batchSize) tooltip += "Training " + font2 + batchSize + font1 + " units; ";
tooltip += "Shift-click to train " + font2 + (batchSize+batchIncrement) + font1 + " units[/font]";
}
}
button.hidden = false;
button.tooltip = tooltip;
button.onpress = (function(e) { return function() { callback(e) } })(item);
// (need nested functions to get the closure right)
icon.sprite = "snPortraitSheetHele"; // TODO
if (typeof template.icon_cell == "undefined")
icon.cell_id = 0;
else
icon.cell_id = template.icon_cell;
++i;
}
var numButtons = i;
// Position the visible buttons
// (TODO: if there's lots, maybe they should be squeezed together to fit)
for (i = 0; i < numButtons; ++i)
{
var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]");
var size = button.size;
size.left = 40*i;
size.right = 40*i + size.bottom;
button.size = size;
}
// Hide any buttons we're no longer using
for (i = numButtons; i < g_unitPanelButtons[guiName]; ++i)
getGUIObjectByName("unit"+guiName+"Button["+i+"]").hidden = true;
g_unitPanelButtons[guiName] = numButtons;
}
function updateUnitDisplay()
{
var detailsPanel = getGUIObjectByName("selectionDetails");
var commandsPanel = getGUIObjectByName("unitCommands");
var selection = g_Selection.toList();
if (selection.length == 0)
{
detailsPanel.hidden = true;
commandsPanel.hidden = true;
return;
}
var entState = Engine.GuiInterfaceCall("GetEntityState", selection[0]);
// If the unit has no data (e.g. it was killed), don't try displaying any
// data for it. (TODO: it should probably be removed from the selection too;
// also need to handle multi-unit selections)
if (!entState)
{
detailsPanel.hidden = true;
commandsPanel.hidden = true;
return;
}
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
detailsPanel.hidden = false;
commandsPanel.hidden = false;
getGUIObjectByName("selectionDetailsIcon").sprite = "snPortraitSheetHele";
getGUIObjectByName("selectionDetailsIcon").cell_id = template.icon_cell;
var healthSize = getGUIObjectByName("selectionDetailsHealthBar").size;
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
getGUIObjectByName("selectionDetailsHealthBar").size = healthSize;
getGUIObjectByName("selectionDetailsHealth").tooltip = "Hitpoints " + entState.hitpoints + " / " + entState.maxHitpoints;
getGUIObjectByName("selectionDetailsSpecific").caption = template.name.specific;
if (template.name.generic == template.name.specific)
{
getGUIObjectByName("selectionDetailsGeneric").hidden = true;
}
else
{
getGUIObjectByName("selectionDetailsGeneric").hidden = false;
getGUIObjectByName("selectionDetailsGeneric").caption = template.name.generic;
}
getGUIObjectByName("selectionDetailsPlayer").caption = "Player " + entState.player; // TODO: get player name
getGUIObjectByName("selectionDetailsAttack").caption = damageTypesToText(entState.attack);
getGUIObjectByName("selectionDetailsArmour").caption = damageTypesToText(entState.armour);
var usedPanels = {};
// If the selection is friendly units, add the command panels
var player = Engine.GetPlayerID();
if (entState.player == player || g_DevSettings.controlAll)
{
if (entState.attack) // TODO - this should be based on some AI properties
{
//usedPanels["Stance"] = 1;
//usedPanels["Formation"] = 1;
// (These are disabled since they're not implemented yet)
}
else // TODO - this should be based on various other things
{
//usedPanels["Research"] = 1;
}
if (entState.buildEntities && entState.buildEntities.length)
setupUnitPanel("Construction", usedPanels, entState, entState.buildEntities, startBuildingPlacement);
if (entState.training && entState.training.entities.length)
setupUnitPanel("Training", usedPanels, entState, entState.training.entities,
function (trainEntType) { addToTrainingQueue(entState.id, trainEntType); } );
if (entState.training && entState.training.queue.length)
setupUnitPanel("Queue", usedPanels, entState, entState.training.queue,
function (item) { removeFromTrainingQueue(entState.id, item.id); } );
}
// Lay out all the used panels in a stack at the bottom of the screen
var offset = 0;
for each (var panelName in g_unitPanels)
{
var panel = getGUIObjectByName("unit"+panelName+"Panel");
if (usedPanels[panelName])
{
var size = panel.size;
var h = size.bottom - size.top;
size.bottom = offset;
size.top = offset - h;
panel.size = size;
panel.hidden = false;
offset -= (h + 12);
}
else
{
panel.hidden = true;
}
}
}
// Cache dev-mode settings that are frequently or widely used
var g_DevSettings = {
controlAll: false
};
function init(initData, hotloadData)
{
if (hotloadData)
{
g_Selection.selected = hotloadData.selection;
}
else
{
// Starting for the first time:
startMusic();
// Preset the Settings Dialog's options based on user's current settings
getGUIObjectByName("shadowsCheckbox").checked = renderer.shadows;
getGUIObjectByName("fancyWaterCheckbox").checked = renderer.fancyWater;
}
onSimulationUpdate();
}
function leaveGame()
{
stopMusic();
endGame();
Engine.SwitchGuiPage("page_pregame.xml");
}
// Return some data that we'll use when hotloading this file after changes
function getHotloadData()
{
return { selection: g_Selection.selected };
}
function onTick()
{
g_DevSettings.controlAll = getGUIObjectByName("devControlAll").checked;
// TODO: at some point this controlAll needs to disable the simulation code's
// player checks (once it has some player checks)
updateCursor();
// If the selection changed, we need to regenerate the sim display
if (g_Selection.dirty)
onSimulationUpdate();
}
function onSimulationUpdate()
{
g_Selection.dirty = false;
var simState = Engine.GuiInterfaceCall("GetSimulationState");
// If we're called during init when the game is first loading, there will be no simulation yet, so do nothing
if (!simState)
return;
updateDebug(simState);
updatePlayerDisplay(simState);
updateUnitDisplay();
}
function updateDebug(simState)
{
var debug = getGUIObjectByName("debug");
if (getGUIObjectByName("devDisplayState").checked)
{
debug.hidden = false;
}
else
{
debug.hidden = true;
return;
}
var text = uneval(simState);
var selection = g_Selection.toList();
if (selection.length)
{
var entState = Engine.GuiInterfaceCall("GetEntityState", selection[g_Selection.getPrimary()]);
if (entState)
{
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
text += "\n\n" + uneval(entState) + "\n\n" + uneval(template);
}
}
debug.caption = text;
}
function updatePlayerDisplay(simState)
{
var playerState = simState.players[Engine.GetPlayerID()];
getGUIObjectByName("resourceFood").caption = playerState.resourceCounts.food;
getGUIObjectByName("resourceWood").caption = playerState.resourceCounts.wood;
getGUIObjectByName("resourceStone").caption = playerState.resourceCounts.stone;
getGUIObjectByName("resourceMetal").caption = playerState.resourceCounts.metal;
getGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
}
//-------------------------------- -------------------------------- --------------------------------
// Utility functions
//-------------------------------- -------------------------------- --------------------------------
function damageTypesToTextStacked(dmg)
{
if (!dmg)
return "(None)";
return dmg.hack + " Hack\n" + dmg.pierce + " Pierce\n" + dmg.crush + " Crush";
}
function damageTypesToText(dmg)
{
if (!dmg)
return "[font=\"serif-12\"](None)[/font]";
var hackLabel = "[font=\"serif-12\"] Hack, [/font]";
var pierceLabel = "[font=\"serif-12\"] Pierce, [/font]";
var crushLabel = "[font=\"serif-12\"] Crush[/font]";
var hackDamage = dmg.hack;
var pierceDamage = dmg.pierce;
var crushDamage = dmg.crush;
return hackDamage + hackLabel + pierceDamage + pierceLabel + crushDamage + crushLabel;
}
function isUnitElite(templateName)
{
var eliteStatus = false;
var firstWord = templateName.substring(0, templateName.search("/"));
var endsWith = templateName.substring(templateName.length-2, templateName.length);
if (firstWord == "units" && endsWith == "_e")
eliteStatus = true;
return eliteStatus;
}
function getFullName(template)
{
var name;
if ((template.name.specific && template.name.generic) && (template.name.specific != template.name.generic))
name = template.name.specific + " (" + template.name.generic + ")";
else
name = template.name.specific || template.name.generic || "???";
return "[font=\"serif-bold-16\"]" + name + "[/font]";
}
function createIconTooltip(entState, template)
{
var tooltip = "";
tooltip = getFullName(template);
var hitpointsLabel = "[font=\"serif-bold-13\"]Hitpoints: [/font]";
tooltip += "\n" + hitpointsLabel + entState.hitpoints + "/" + entState.maxHitpoints;
var attackLabel = "[font=\"serif-bold-13\"]Attack: [/font]";
var armourLabel = "[font=\"serif-bold-13\"]Armour: [/font]";
tooltip += "\n" + attackLabel + damageTypesToText(entState.attack) + "\n" + armourLabel + damageTypesToText(entState.armour);
return tooltip;
}
//-------------------------------- -------------------------------- --------------------------------
// Menu Functions
//-------------------------------- -------------------------------- --------------------------------
function toggleDeveloperOverlay()
{
if (getGUIObjectByName("devCommands").hidden)
getGUIObjectByName("devCommands").hidden = false; // show overlay
else
getGUIObjectByName("devCommands").hidden = true; // hide overlay
}
function toggleSettingsWindow()
{
if (getGUIObjectByName("settingsWindow").hidden)
{
getGUIObjectByName("settingsWindow").hidden = false; // show settings
setPaused(true);
}
else
{
getGUIObjectByName("settingsWindow").hidden = true; // hide settings
setPaused(false);
}
getGUIObjectByName("menu").hidden = true; // Hide menu
}
function togglePause()
{
if (getGUIObjectByName("pauseOverlay").hidden)
{
getGUIObjectByName("pauseOverlay").hidden = false; // pause game
setPaused(true);
}
else
{
getGUIObjectByName("pauseOverlay").hidden = true; // unpause game
setPaused(false);
}
getGUIObjectByName("menu").hidden = true; // Hide menu
}
function toggleMenu()
{
if (getGUIObjectByName("menu").hidden)
getGUIObjectByName("menu").hidden = false; // View menu
else
getGUIObjectByName("menu").hidden = true; // Hide menu
}
//-------------------------------- -------------------------------- --------------------------------
// View / Hide Details Panel and Commands Panel information
//-------------------------------- -------------------------------- --------------------------------
// Hides Details Panel's Information
function hideSelectionDetails(booleanValue)
{
getGUIObjectByName("selectionDetailsIcon").hidden = booleanValue;
getGUIObjectByName("selectionDetailsHealth").hidden = booleanValue;
getGUIObjectByName("selectionDetailsStamina").hidden = booleanValue;
getGUIObjectByName("selectionDetailsMainText").hidden = booleanValue;
getGUIObjectByName("selectionDetailsAttack").hidden = booleanValue;
getGUIObjectByName("selectionDetailsArmour").hidden = booleanValue;
getGUIObjectByName("unitSelectionPanel").hidden = booleanValue;
getGUIObjectByName("selectionProductLogo").hidden = !booleanValue; // gets opposite of booleanValue
}
// Hides Commands Panel's Information
function hideCommands(booleanValue)
{
getGUIObjectByName("unitConstructionPanel").hidden = booleanValue;
getGUIObjectByName("unitStancePanel").hidden = booleanValue;
getGUIObjectByName("unitFormationPanel").hidden = booleanValue;
getGUIObjectByName("unitResearchPanel").hidden = booleanValue;
getGUIObjectByName("unitTrainingPanel").hidden = booleanValue;
getGUIObjectByName("unitQueuePanel").hidden = booleanValue;
}
//-------------------------------- -------------------------------- --------------------------------
// Details Panel layout
//-------------------------------- -------------------------------- --------------------------------
// Multiple Selection Layout
function selectionLayoutMultiple()
{
getGUIObjectByName("selectionDetailsMainText").size = "110 100%-74 100%-20 100%-20";
getGUIObjectByName("selectionDetailsSpecific").size = "0 0 100% 24";
getGUIObjectByName("selectionDetailsPlayer").size = "0 30 100% 50";
getGUIObjectByName("selectionDetailsIcon").size = "16 100%-94 88 100%-22";
getGUIObjectByName("selectionDetailsHealth").size = "16 100%-20 88 100%-14";
getGUIObjectByName("selectionDetailsStamina").size = "16 100%-12 88 100%-6";
getGUIObjectByName("selectionDetailsAttack").hidden = true;
getGUIObjectByName("selectionDetailsArmour").hidden = true;
getGUIObjectByName("selectionDetailsMainText").sprite = "goldPanel";
getGUIObjectByName("selectionDetailsSpecific").sprite = "";
}
// Single Selection Layout
function selectionLayoutSingle()
{
getGUIObjectByName("selectionDetailsMainText").size = "10 0 100%-10 56";
getGUIObjectByName("selectionDetailsSpecific").size = "0 0 100% 30";
getGUIObjectByName("selectionDetailsPlayer").size = "0 30 100% 56";
getGUIObjectByName("selectionDetailsIcon").size = "16 100%-118 112 100%-22";
getGUIObjectByName("selectionDetailsHealth").size = "16 100%-20 112 100%-14";
getGUIObjectByName("selectionDetailsStamina").size = "16 100%-12 112 100%-6";
getGUIObjectByName("selectionDetailsAttack").hidden = false;
getGUIObjectByName("selectionDetailsArmour").hidden = false;
getGUIObjectByName("selectionDetailsMainText").sprite = "";
getGUIObjectByName("selectionDetailsSpecific").sprite = "wheatWindowTitle";
}
// The number of currently visible buttons (used to optimise showing/hiding)
var g_unitPanelButtons = { "Construction": 0, "Training": 0, "Queue": 0 };
// Unit panels are panels with row(s) of buttons
var g_unitPanels = ["Stance", "Formation", "Construction", "Research", "Training", "Queue", "Selection"];
//-------------------------------- -------------------------------- --------------------------------
// Sets up "unit panels" - the panels with rows of icons (Helper function for updateUnitDisplay)
//-------------------------------- -------------------------------- --------------------------------
function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
{
usedPanels[guiName] = 1;
var i = 0;
// End loop early if more than 18 selection buttons or more than 16 other types of buttons
var MAX_NUM_BUTTONS = ((guiName == "Selection")? 17 : 15 );
for each (var item in items)
{
if (i > MAX_NUM_BUTTONS)
break;
// Get templates
var entType;
if (guiName == "Queue")
entType = item.template;
else
entType = item;
var template = Engine.GuiInterfaceCall("GetTemplateData", entType);
if (!template)
continue; // ignore attempts to use invalid templates (an error should have been reported already)
// Name
var name;
if (guiName == "Selection")
name = template.name.specific || template.name.generic || "???";
else
name = getFullName(template);
// Tooltip
var tooltip = (isUnitElite(entType)? "Elite " + name : name ); // "Elite " is not formatted in bold, so may need custom versions of this later
if (guiName == "Selection")
{
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption =
(g_Selection.groups.groupTypeCount[item] > 1 ? g_Selection.groups.groupTypeCount[item] : "");
tooltip += (g_Selection.groups.groupTypeCount[item] > 1 ? " (" + g_Selection.groups.groupTypeCount[item] + ")" : "")
}
else if (guiName == "Queue")
{
var progress = Math.round(item.progress*100) + "%";
tooltip += " - " + progress;
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (item.count > 1 ? item.count : "");
getGUIObjectByName("unit"+guiName+"Progress["+i+"]").caption = (item.progress ? progress : "");
}
else if (guiName == "Construction" || guiName == "Training")
{
if (template.cost)
{
var costs = [];
if (template.cost.food) costs.push("[font=\"serif-bold-13\"]Food:[/font] " + template.cost.food);
if (template.cost.wood) costs.push("[font=\"serif-bold-13\"]Wood:[/font] " + template.cost.wood);
if (template.cost.metal) costs.push("[font=\"serif-bold-13\"]Metal:[/font] " + template.cost.metal);
if (template.cost.stone) costs.push("[font=\"serif-bold-13\"]Stone:[/font] " + template.cost.stone);
if (costs.length)
tooltip += "\n" + costs.join(", ");
}
if (guiName == "Training")
{
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
tooltip += "\n[font=\"serif-13\"]";
if (batchSize) tooltip += "Training [font=\"serif-bold-13\"]" + batchSize + "[font=\"serif-13\"] units; ";
tooltip += "Shift-click to train [font=\"serif-bold-13\"]"+ (batchSize+batchIncrement) + "[font=\"serif-13\"] units[/font]";
}
}
// Button
var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]");
var icon = getGUIObjectByName("unit"+guiName+"Icon["+i+"]");
button.hidden = false;
button.tooltip = tooltip;
if (callback != null)
button.onpress = (function(e) { return function() { callback(e) } })(item); // (need nested functions to get the closure right)
icon.sprite = "snPortraitSheetHele"; // TODO
if (typeof template.icon_cell == "undefined")
icon.cell_id = 0;
else
icon.cell_id = template.icon_cell;
++i;
}
// Position the visible buttons (TODO: if there's lots, maybe they should be squeezed together to fit)
var buttonSideLength = getGUIObjectByName("unit"+guiName+"Button[0]").size.bottom;
var numButtons = i;
var j = 0;
for (i = 0; i < numButtons; ++i)
{
var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]");
var size = button.size;
if (guiName == "Selection") // Smaller Icons
{
if (i > 8) // Make first row
{
size.left = 30*j;
size.right = 30*j + buttonSideLength;
size.top = 30;
size.bottom = 30 + buttonSideLength;
j++;
}
else // Make second row
{
size.left = 30*i;
size.right = 30*i + size.bottom;
}
}
else // Larger Icons
{
size.left = 40*i;
size.right = 40*i + size.bottom;
}
button.size = size;
}
// Hide any buttons we're no longer using
for (i = numButtons; i < g_unitPanelButtons[guiName]; ++i)
getGUIObjectByName("unit"+guiName+"Button["+i+"]").hidden = true;
g_unitPanelButtons[guiName] = numButtons;
}
//-------------------------------- -------------------------------- --------------------------------
// Updates middle Selection Details Panel - runs in the main session loop
//-------------------------------- -------------------------------- --------------------------------
function updateUnitDisplay()
{
var detailsPanel = getGUIObjectByName("selectionDetails");
var commandsPanel = getGUIObjectByName("unitCommands");
var selection = g_Selection.toList();
if (selection.length == 0)
{
hideSelectionDetails(true);
hideCommands(true);
return;
}
var entState = Engine.GuiInterfaceCall("GetEntityState", selection[g_Selection.getPrimary()]);
/* If the unit has no data (e.g. it was killed), don't try displaying any
data for it. (TODO: it should probably be removed from the selection too;
also need to handle multi-unit selections) */
if (!entState)
{
hideSelectionDetails(true);
hideCommands(true);
return;
}
hideSelectionDetails(false);
hideCommands(false);
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
var iconTooltip = "";
// Hitpoints
if (entState.hitpoints != undefined)
{
var healthSize = getGUIObjectByName("selectionDetailsHealthBar").size;
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
getGUIObjectByName("selectionDetailsHealthBar").size = healthSize;
getGUIObjectByName("selectionDetailsHealth").tooltip = "Hitpoints " + entState.hitpoints + " / " + entState.maxHitpoints;
getGUIObjectByName("selectionDetailsHealth").hidden = false;
}
else
{
getGUIObjectByName("selectionDetailsHealth").hidden = true;
getGUIObjectByName("selectionDetailsHealth").tooltip = "";
}
// Stamina
// if (entState.stamina != undefined)
getGUIObjectByName("selectionDetailsStamina").hidden = false;
// else
// getGUIObjectByName("selectionDetailsStamina").hidden = true;
// Is unit Elite?
var eliteStatus = isUnitElite(entState.template);
// Specific Name
getGUIObjectByName("selectionDetailsSpecific").caption = (eliteStatus? "Elite " + template.name.specific : template.name.specific );
// Generic Name
if (template.name.generic == template.name.specific)
{
getGUIObjectByName("selectionDetailsGeneric").hidden = true;
getGUIObjectByName("selectionDetailsSpecific").tooltip = "";
//iconTooltip += template.name.specific;
}
else
{
getGUIObjectByName("selectionDetailsSpecific").tooltip = template.name.generic;
//iconTooltip += template.name.specific + " (" + template.name.generic + ")";
}
// Player Name
getGUIObjectByName("selectionDetailsPlayer").caption = "Player " + entState.player; // TODO: get player name
// Icon
iconTooltip += (eliteStatus? "[font=\"serif-bold-16\"]Elite [/font]" : "");
iconTooltip += createIconTooltip(entState, template);
getGUIObjectByName("selectionDetailsIconImage").tooltip = iconTooltip;
getGUIObjectByName("selectionDetailsIconImage").sprite = "snPortraitSheetHele";
getGUIObjectByName("selectionDetailsIconImage").cell_id = template.icon_cell;
// Attack and Armour Stats
getGUIObjectByName("selectionDetailsAttackStats").caption = damageTypesToTextStacked(entState.attack);
getGUIObjectByName("selectionDetailsArmourStats").caption = damageTypesToTextStacked(entState.armour);
// Different selection details are shown based on whether multiple units or a single unit is selected
if (selection.length > 1)
selectionLayoutMultiple();
else
selectionLayoutSingle();
// Panels that are active
var usedPanels = {};
// If the selection is friendly units, add the command panels
var player = Engine.GetPlayerID();
if (entState.player == player || g_DevSettings.controlAll)
{
if (entState.attack) // TODO - this should be based on some AI properties
{
//usedPanels["Stance"] = 1;
//usedPanels["Formation"] = 1;
// (These are disabled since they're not implemented yet)
}
else // TODO - this should be based on various other things
{
//usedPanels["Research"] = 1;
}
if (entState.buildEntities && entState.buildEntities.length)
setupUnitPanel("Construction", usedPanels, entState, entState.buildEntities, startBuildingPlacement);
if (entState.training && entState.training.entities.length)
setupUnitPanel("Training", usedPanels, entState, entState.training.entities,
function (trainEntType) { addToTrainingQueue(entState.id, trainEntType); } );
if (entState.training && entState.training.queue.length)
setupUnitPanel("Queue", usedPanels, entState, entState.training.queue,
function (item) { removeFromTrainingQueue(entState.id, item.id); } );
if (selection.length > 1)
setupUnitPanel("Selection", usedPanels, entState, g_Selection.groups.groupTemplates,
function (entType) { changePrimarySelectionGroup(entType); } );
}
// Hides / unhides Unit Panels (panels should be grouped by type, not by order, but we will leave that for another time)
var offset = 0;
for each (var panelName in g_unitPanels)
{
var panel = getGUIObjectByName("unit" + panelName + "Panel");
if (usedPanels[panelName])
{
// var size = panel.size;
// var h = size.bottom - size.top;
// size.bottom = offset;
// size.top = offset - h;
// panel.size = size;
panel.hidden = false;
// offset -= (h + 6); // changed 12 point spacing to 6 point: offset -= (h + 12);
}
else
{
panel.hidden = true;
}
}
}
@@ -1,275 +1,456 @@
<?xml version="1.0" encoding="utf-8"?>
<objects>
<script file="gui/common/functions_global_object.js" />
<script file="gui/session_new/session.js"/>
<script file="gui/session_new/selection.js"/>
<script file="gui/session_new/input.js"/>
<script file="gui/session_new/music.js"/>
<object name="sn" hotkey="session.gui.toggle">
<action on="Tick">
onTick();
</action>
<action on="SimulationUpdate">
onSimulationUpdate();
</action>
<action on="Press">
this.hidden = !this.hidden;
</action>
<!-- Exit button -->
<object type="button" style="wheatExit"
size="100%-16 0 100% 16"
tooltip_style="snToolTip"
tooltip="Exit game"
hotkey="leave"
>
<action on="Press"><![CDATA[
messageBox(400, 200, "Do you really want to quit?", "Confirmation", 0,
["Yes", "No!"], [leaveGame, null]);
]]></action>
</object>
<!-- Dev/cheat commands -->
<object size="100%-170 32 100%-16 144" type="image" sprite="devCommandsBackground">
<object size="0 0 100%-18 16" type="text" style="devCommandsText">Control all units</object>
<object size="100%-16 0 100% 16" type="checkbox" name="devControlAll" style="wheatCrossBox"/>
<object size="0 16 100%-18 32" type="text" style="devCommandsText">Display selection state</object>
<object size="100%-16 16 100% 32" type="checkbox" name="devDisplayState" style="wheatCrossBox"/>
<object size="0 32 100%-18 48" type="text" style="devCommandsText">Pathfinder overlay</object>
<object size="100%-16 32 100% 48" type="checkbox" style="wheatCrossBox">
<action on="Press">Engine.GuiInterfaceCall("SetPathfinderDebugOverlay", this.checked);</action>
</object>
<object size="0 48 100%-18 64" type="text" style="devCommandsText">Obstruction overlay</object>
<object size="100%-16 48 100% 64" type="checkbox" style="wheatCrossBox">
<action on="Press">Engine.GuiInterfaceCall("SetObstructionDebugOverlay", this.checked);</action>
</object>
<object size="0 64 100%-18 80" type="text" style="devCommandsText">Unit motion overlay</object>
<object size="100%-16 64 100% 80" type="checkbox" style="wheatCrossBox">
<action on="Press">g_Selection.SetMotionDebugOverlay(this.checked);</action>
</object>
<object size="0 80 100%-18 96" type="text" style="devCommandsText">Toggle music</object>
<object size="100%-16 80 100% 96" type="checkbox" style="wheatCrossBox" checked="true" hotkey="music.toggle">
<action on="Press">if (this.checked) startMusic(); else stopMusic();</action>
</object>
<object size="0 96 100%-18 112" type="text" style="devCommandsText">Pause game</object>
<object size="100%-16 96 100% 112" type="checkbox" style="wheatCrossBox" hotkey="pause">
<action on="Press">setPaused(this.checked);</action>
</object>
</object>
<!-- Debug text -->
<object name="debug"
type="text"
size="0 50 50% 100%"
ghost="true"
textcolor="yellow"
font="mono-stroke-10"
/>
<!-- Player resource bar -->
<object
size="50%-200 0 50%+200 30"
type="image"
style="goldPanelFrilly"
>
<!-- Food -->
<object size="0 0 18% 100%" type="image" style="resourceCounter" tooltip="Food">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="0"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceFood"/>
</object>
<!-- Wood -->
<object size="18% 0 36% 100%" type="image" style="resourceCounter" tooltip="Wood">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="1"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceWood"/>
</object>
<!-- Stone -->
<object size="36% 0 54% 100%" type="image" style="resourceCounter" tooltip="Stone">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="2"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceStone"/>
</object>
<!-- Metal -->
<object size="54% 0 72% 100%" type="image" style="resourceCounter" tooltip="Metal">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="3"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceMetal"/>
</object>
<!-- Population -->
<object size="72% 0 100% 100%" type="image" style="resourceCounter" tooltip="Population (current / maximum)">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="4"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourcePop"/>
</object>
</object>
<!-- Bottom-left selected-unit details panel -->
<object name="selectionDetails"
type="image"
style="goldPanel"
size="0 100%-250 300 100%"
>
<!-- Big unit icon -->
<object size="8 8 136 136">
<object type="image" style="selectionDetailsIconOutline"/>
<object type="image" name="selectionDetailsIcon" ghost="true"/>
</object>
<!-- Health bar -->
<object size="8 138 136 144" type="image" name="selectionDetailsHealth" tooltip="Hitpoints" tooltip_style="snToolTip">
<object type="image" sprite="selectionDetailsHealthBackground" ghost="true"/>
<object type="image" sprite="selectionDetailsHealthForeground" ghost="true" name="selectionDetailsHealthBar"/>
</object>
<!-- Stamina bar -->
<object size="8 146 136 152" type="image" name="selectionDetailsStamina" tooltip="Stamina" tooltip_style="snToolTip">
<object type="image" sprite="selectionDetailsStaminaBackground" ghost="true"/>
<object type="image" sprite="selectionDetailsStaminaForeground" ghost="true" name="selectionDetailsStaminaBar"/>
</object>
<!-- Details text -->
<object size="136 6 100% 100%">
<object size="0 0 100% 30" name="selectionDetailsSpecific" type="text" font="serif-bold-18"/>
<object size="0 20 100% 40" name="selectionDetailsGeneric" type="text" font="serif-14"/>
<object size="0 40 100% 60" name="selectionDetailsPlayer" type="text" font="serif-14" textcolor="blue"/>
</object>
<!-- Attack stats -->
<object size="146 72 100% 130" type="image" tooltip="Attack strengths" tooltip_style="snToolTip">
<object size="-4 -8 48 48" type="image" ghost="true" sprite="snIconSheetStance" cell_id="1"/>
<object size="40 0 100% 100%" type="text" ghost="true" name="selectionDetailsAttack" font="serif-bold-12"/>
</object>
<!-- Armour stats -->
<object size="146 130 100% 188" type="image" tooltip="Armour strengths" tooltip_style="snToolTip">
<object size="-4 -4 48 48" type="image" ghost="true" sprite="snIconSheetStance" cell_id="3"/>
<object size="40 0 100% 100%" type="text" ghost="true" name="selectionDetailsArmour" font="serif-bold-12"/>
</object>
</object>
<!-- Bottom-middle selected-unit commands panel -->
<object name="unitCommands"
size="350 0 100%-300 100%-8"
>
<object name="unitConstructionPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="image"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="0" tooltip="Construction"/>
<object size="59 10 100% 47">
<repeat count="16">
<object name="unitConstructionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 37 37">
<object name="unitConstructionIcon[n]" type="image" ghost="true" size="3 3 35 35"/>
</object>
</repeat>
</object>
</object>
<object name="unitStancePanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="4" tooltip="Stances"/>
[stance commands]
</object>
<object name="unitFormationPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="5" tooltip="Formations"/>
[formation commands]
</object>
<object name="unitResearchPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="1" tooltip="Research"/>
[research commands]
</object>
<object name="unitTrainingPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="image"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="2" tooltip="Training"/>
<object size="59 10 100% 47">
<repeat count="16">
<object name="unitTrainingButton[n]" hidden="true" style="iconButton" type="button" size="0 0 37 37">
<object name="unitTrainingIcon[n]" type="image" ghost="true" size="3 3 35 35"/>
</object>
</repeat>
</object>
</object>
<object name="unitQueuePanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="3" tooltip="Production queue"/>
<object size="59 10 100% 47">
<repeat count="16">
<object name="unitQueueButton[n]" hidden="true" style="iconButton" type="button" size="0 0 37 37">
<object name="unitQueueIcon[n]" ghost="true" type="image" size="3 3 35 35"/>
<object name="unitQueueCount[n]" ghost="true" style="iconButtonCount" type="text"/>
<object name="unitQueueProgress[n]" ghost="true" style="iconButtonProgress" type="text"/>
</object>
</repeat>
</object>
</object>
</object>
<!-- Minimap -->
<object name="minimap">
<object style="goldPanel"
size="100%-246 100%-246 100% 100%"
type="image"
/>
<object name="minimapDisplay"
type="minimap"
size="100%-206 100%-206 100%-6 100%-6"
/>
</object>
</object>
<!-- Selection bandbox -->
<object name="bandbox" type="image" sprite="bandbox" ghost="true" hidden="true"/>
</objects>
<?xml version="1.0" encoding="utf-8"?>
<objects>
<script file="gui/common/functions_global_object.js" />
<script file="gui/session_new/session.js"/>
<script file="gui/session_new/selection.js"/>
<script file="gui/session_new/input.js"/>
<script file="gui/session_new/music.js"/>
<object name="sn" hotkey="session.gui.toggle">
<action on="Tick">
onTick();
</action>
<action on="SimulationUpdate">
onSimulationUpdate();
</action>
<action on="Press">
this.hidden = !this.hidden;
</action>
<!-- ================================ ================================ -->
<!-- ALPHA LABELS (alpha, build time, revision) -->
<!-- ================================ ================================ -->
<!-- Displays Alpha name and number -->
<object size="100%-170 0 100%-8 25" name="alphaLabel" type="text" style="centeredText" font="serif-bold-16" textcolor="white">
<action on="Load"><![CDATA[this.caption = "ALPHA I : Argonaut";]]></action>
</object>
<!-- Displays build date and revision number-->
<object size="100%-170 25 100%-8 45" name="buildTimeLabel" type="text" style="centeredText" font="serif-12" textcolor="white">
<action on="Load"><![CDATA[this.caption = buildTime(0) + " (" + buildTime(2) + ")";]]></action>
</object>
<!-- ================================ ================================ -->
<!-- HOTKEYS (For some reason, they won't work properly unless outside menu) -->
<!-- ================================ ================================ -->
<!-- Exit button Hotkey -->
<object hotkey="leave">
<action on="Press"><![CDATA[
messageBox(400, 200, "Do you really want to quit?", "Confirmation", 0,
["Yes", "No!"], [leaveGame, null]);
]]></action>
</object>
<!-- ================================ ================================ -->
<!-- Developer / Debug items -->
<!-- ================================ ================================ -->
<!-- Debug text -->
<object name="debug"
type="text"
size="0 50 50% 100%"
ghost="true"
textcolor="yellow"
font="mono-stroke-10"
/>
<!-- Dev/cheat commands -->
<object z="200" size="100%-155 50 100%-16 130" type="image" name="devCommands" sprite="devCommandsBackground" hidden="true">
<object size="0 0 100%-18 16" type="text" style="devCommandsText">Control all units</object>
<object size="100%-16 0 100% 16" type="checkbox" name="devControlAll" style="wheatCrossBox"/>
<object size="0 16 100%-18 32" type="text" style="devCommandsText">Display selection state</object>
<object size="100%-16 16 100% 32" type="checkbox" name="devDisplayState" style="wheatCrossBox"/>
<object size="0 32 100%-18 48" type="text" style="devCommandsText">Pathfinder overlay</object>
<object size="100%-16 32 100% 48" type="checkbox" style="wheatCrossBox">
<action on="Press">Engine.GuiInterfaceCall("SetPathfinderDebugOverlay", this.checked);</action>
</object>
<object size="0 48 100%-18 64" type="text" style="devCommandsText">Obstruction overlay</object>
<object size="100%-16 48 100% 64" type="checkbox" style="wheatCrossBox">
<action on="Press">Engine.GuiInterfaceCall("SetObstructionDebugOverlay", this.checked);</action>
</object>
<object size="0 64 100%-18 80" type="text" style="devCommandsText">Unit motion overlay</object>
<object size="100%-16 64 100% 80" type="checkbox" style="wheatCrossBox">
<action on="Press">g_Selection.SetMotionDebugOverlay(this.checked);</action>
</object>
<!--
<object size="0 80 100%-18 96" type="text" style="devCommandsText">Toggle music</object>
<object size="100%-16 80 100% 96" type="checkbox" style="wheatCrossBox" checked="true" hotkey="music.toggle">
<action on="Press">if (this.checked) startMusic(); else stopMusic();</action>
</object>
<object size="0 96 100%-18 112" type="text" style="devCommandsText">Pause game</object>
<object size="100%-16 96 100% 112" type="checkbox" style="wheatCrossBox" hotkey="pause">
<action on="Press">setPaused(this.checked);</action>
</object>
-->
</object>
<!-- ================================ ================================ -->
<!-- Pause Overlay -->
<!-- ================================ ================================ -->
<object type="button"
name="pauseOverlay"
size="0 0 100% 100%"
tooltip_style="snToolTip"
tooltip="Click to Unpause Game"
hidden="true"
z="0"
>
<object size="0 0 100% 100%" type="image" sprite="devCommandsBackground" ghost="true" z="0"/>
<object size="0 0 100% 100%" type="text" style="largeBoldCenteredText" textcolor="white" ghost="true" z="0">Game Paused</object>
<action on="Press">togglePause();</action>
</object>
<!-- ================================ ================================ -->
<!-- Settings Window -->
<!-- ================================ ================================ -->
<object name="settingsWindow"
style="wheatWindow"
type="image"
size="50%-180 50%-200 50%+180 50%+50"
hidden="true"
z="50"
>
<object name="settingsTitleBar" style="wheatWindowTitleBar" type="text">Settings</object>
<object name="settingsOptions"
size="30 30 100%-30 150"
type="image"
style="goldPanel"
>
<object size="0 10 100%-80 35" type="text" style="settingsText" ghost="true">Enable Shadows</object>
<object name="shadowsCheckbox" size="100%-56 15 100%-30 40" type="checkbox" style="wheatCrossBox" checked="true">
<action on="Press">renderer.shadows = this.checked;</action>
</object>
<object size="0 35 100%-80 60" type="text" style="settingsText" ghost="true">Enable Water Reflections</object>
<object name="fancyWaterCheckbox" size="100%-56 40 100%-30 65" type="checkbox" style="wheatCrossBox" checked="true">
<action on="Press">renderer.fancyWater = this.checked;</action>
</object>
<object size="0 60 100%-80 85" type="text" style="settingsText" ghost="true">Toggle Music</object>
<object size="100%-56 65 100%-30 90" type="checkbox" style="wheatCrossBox" checked="true">
<action on="Press">if (this.checked) startMusic(); else stopMusic();</action>
</object>
<object size="0 85 100%-80 110" type="text" style="settingsText" ghost="true">Developer Overlay</object>
<object size="100%-56 90 100%-30 115" type="checkbox" style="wheatCrossBox" checked="false">
<action on="Press">if (this.checked) toggleDeveloperOverlay(); else toggleDeveloperOverlay();</action>
</object>
</object>
<object name="settingsOKButton"
style="wheatButtonFancy"
type="button"
size="50%-50 100%-52 50%+50 100%-20"
>
<object size="0 0 100% 100%" type="text" style="centeredText" name="settingsOKButtonText" ghost="true">OK</object>
<action on="Press">toggleSettingsWindow();</action>
</object>
</object>
<!-- ================================ ================================ -->
<!-- Menu Details -->
<!-- ================================ ================================ -->
<object name="menu"
size="0 0 114 128"
type="image"
sprite="devCommandsBackground"
hidden="true"
>
<!-- Settings button -->
<object type="button"
name="settingsButton"
style="wheatButtonFancy"
size="0 32 114 64"
tooltip_style="snToolTip"
>
<object size="0 0 100% 100%" type="text" style="centeredText" name="settingsButtonText" ghost="true">Settings</object>
<action on="Press">toggleSettingsWindow();</action>
</object>
<!-- Pause Button -->
<object type="button"
style="wheatButtonFancy"
name="pauseButton"
size="0 64 114 96"
tooltip_style="snToolTip"
>
<object size="0 0 100% 100%" type="text" ghost="true" style="centeredText">Pause Game</object>
<action on="Press">togglePause();</action>
</object>
<!-- Exit button -->
<object type="button"
name="exitButton"
style="wheatButtonFancy"
size="0 96 114 128"
tooltip_style="snToolTip"
>
<object size="0 0 100% 100%" type="text" style="centeredText" name="exitButtonText" ghost="true" font="serif-14">Quit Game</object>
<action on="Press">
toggleMenu();
<![CDATA[messageBox(400, 200, "Do you really want to quit?", "Confirmation", 0, ["Yes", "No!"], [leaveGame, null]);]]>
</action>
</object>
</object>
<!-- Menu Button -->
<object type="button"
name="menuButton"
style="wheatButtonFancy"
size="0 0 114 32"
tooltip_style="snToolTip"
>
<object size="0 0 100% 100%" type="text" style="largeBoldCenteredText" name="menuButtonText" ghost="true">Menu</object>
<action on="Press">toggleMenu();</action>
</object>
<!-- ================================ ================================ -->
<!-- Bottom-left Minimap and Resource Panel-->
<!-- ================================ ================================ -->
<object
name="mapAndResourcePanel"
style="goldPanel"
size="0 100%-188 280 100%"
type="image"
z="30"
>
<!-- Minimap -->
<object name="minimap">
<object
size="24 100%-164 164 100%-24"
type="image"
style="wheatWindow"
/>
<object name="minimapDisplay"
type="minimap"
size="6 6 182 182"
/>
</object>
<!-- Player resource bar -->
<object
size="192 100%-120 280 100%"
>
<!-- Food -->
<object size="0 0 100% 100%" type="image" style="resourceCounter" tooltip="Food">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="0"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceFood"/>
</object>
<!-- Wood -->
<object size="0 18% 100% 100%" type="image" style="resourceCounter" tooltip="Wood">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="1"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceWood"/>
</object>
<!-- Stone -->
<object size="0 36% 100% 100%" type="image" style="resourceCounter" tooltip="Stone">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="2"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceStone"/>
</object>
<!-- Metal -->
<object size="0 54% 100% 100%" type="image" style="resourceCounter" tooltip="Metal">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="3"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceMetal"/>
</object>
<!-- Population -->
<object size="0 72% 100% 100%" type="image" style="resourceCounter" tooltip="Population (current / maximum)">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="4"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourcePop"/>
</object>
</object>
</object>
<!-- ================================ ================================ -->
<!-- Bottom-middle selected-units and unit details panel -->
<!-- ================================ ================================ -->
<object name="selectionDetails"
type="image"
style="goldPanel"
size="280 100%-178 600 100%"
z="20"
>
<!-- OAD logo background-->
<object name="selectionProductLogo"
size="75 50 100%-75 100%-50"
type="image"
style="frilly"
hidden="false"
>
<object name="selectionProductLogoImage"
type="image"
size="-4 -7 100%+24 100%+13"
sprite="watermarkProduct"
/>
</object>
<!-- Unit Selection Area -->
<object name="unitSelectionPanel"
size="20 6 100%-20 74"
type="image"
style="goldPanel"
>
<object size="6 6 100% 47">
<repeat count="18">
<object name="unitSelectionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 27 27" z="20">
<object name="unitSelectionHighlight[n]" hidden="true" ghost="true" type="image" sprite="primaryGroupHighlight" size="-1 -1 28 28"/>
<object name="unitSelectionIcon[n]" type="image" ghost="true" size="3 3 25 25"/>
<object name="unitSelectionCount[n]" ghost="true" style="groupIconsText" type="text"/>
</object>
</repeat>
</object>
</object>
<!-- Big unit icon -->
<object size="16 100%-94 88 100%-22" name="selectionDetailsIcon" >
<object type="image" style="selectionDetailsIconOutline"/>
<object type="image" name="selectionDetailsIconImage" tooltip_style="snToolTip"/>
</object>
<!-- Health bar -->
<object size="16 100%-20 88 100%-14" type="image" name="selectionDetailsHealth" tooltip="Hitpoints" tooltip_style="snToolTip">
<object type="image" sprite="selectionDetailsHealthBackground" ghost="true"/>
<object type="image" sprite="selectionDetailsHealthForeground" ghost="true" name="selectionDetailsHealthBar"/>
</object>
<!-- Stamina bar -->
<object size="16 100%-12 88 100%-6" type="image" name="selectionDetailsStamina" tooltip="Stamina" tooltip_style="snToolTip">
<object type="image" sprite="selectionDetailsStaminaBackground" ghost="true"/>
<object type="image" sprite="selectionDetailsStaminaForeground" ghost="true" name="selectionDetailsStaminaBar"/>
</object>
<!-- Details text -->
<object size="10 0 100%-10 56" name="selectionDetailsMainText" type="image" sprite="wheatWindowTitle">
<object size="0 5 100% 30" name="selectionDetailsSpecific" type="text" style="largeBoldCenteredText" tooltip_style="snToolTip"/>
<object hidden="true" size="0 20 100% 40" name="selectionDetailsGeneric" type="text" font="serif-14"/>
<object size="0 30 100% 50" name="selectionDetailsPlayer" type="text" style="centeredText" font="serif-14" textcolor="blue"/>
</object>
<!-- Attack stats -->
<object hidden="true" size="120 58 100% 108" type="image" name="selectionDetailsAttack" tooltip="Attack strengths" tooltip_style="snToolTip">
<object size="-4 -8 36 36" type="image" name="selectionDetailsAttackImage" ghost="true" sprite="snIconSheetStance" cell_id="1"/>
<object size="40 0 100% 100%" type="text" name="selectionDetailsAttackStats" ghost="true" font="serif-bold-12"/>
</object>
<!-- Armour stats -->
<object hidden="true" size="120 122 100% 172" type="image" name="selectionDetailsArmour" tooltip="Armour strengths" tooltip_style="snToolTip">
<object size="-4 -4 36 36" type="image" name="selectionDetailsArmourImage" ghost="true" sprite="snIconSheetStance" cell_id="3"/>
<object size="40 0 100% 100%" type="text" name="selectionDetailsArmourStats" ghost="true" font="serif-bold-12"/>
</object>
</object>
<!-- ================================ ================================ -->
<!-- Bottom-right commands panel -->
<!-- ================================ ================================ -->
<object name="unitCommands"
type="image"
style="goldPanel"
size="600 100%-168 100% 100%"
>
<object name="unitConstructionPanel"
size="4 0 100% 33%"
>
<object size="0 -2 64 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="0" tooltip="Construction"/>
<object size="64 10 100% 47">
<repeat count="16">
<object name="unitConstructionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 37 37">
<object name="unitConstructionIcon[n]" type="image" ghost="true" size="3 3 35 35"/>
</object>
</repeat>
</object>
</object>
<object name="unitStancePanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="4" tooltip="Stances"/>
[stance commands]
</object>
<object name="unitFormationPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="5" tooltip="Formations"/>
[formation commands]
</object>
<object name="unitResearchPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="1" tooltip="Research"/>
[research commands]
</object>
<object name="unitTrainingPanel"
size="4 0 100% 33%"
>
<object size="0 -2 64 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="2" tooltip="Training"/>
<object size="64 10 100% 47">
<repeat count="16">
<object name="unitTrainingButton[n]" hidden="true" style="iconButton" type="button" size="0 0 37 37">
<object name="unitTrainingIcon[n]" type="image" ghost="true" size="3 3 35 35"/>
</object>
</repeat>
</object>
</object>
<object name="unitQueuePanel"
style="goldPanelFrilly"
size="4 -62 100% 100%-174"
type="image"
>
<object size="0 -2 64 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="3" tooltip="Production queue"/>
<object size="64 10 100% 47">
<repeat count="16">
<object name="unitQueueButton[n]" hidden="true" style="iconButton" type="button" size="0 0 37 37">
<object name="unitQueueIcon[n]" ghost="true" type="image" size="3 3 35 35"/>
<object name="unitQueueCount[n]" ghost="true" style="iconButtonCount" type="text"/>
<object name="unitQueueProgress[n]" ghost="true" style="iconButtonProgress" type="text"/>
</object>
</repeat>
</object>
</object>
</object>
</object>
<!-- ================================ ================================ -->
<!-- Selection bandbox -->
<!-- ================================ ================================ -->
<object name="bandbox" type="image" sprite="bandbox" ghost="true" hidden="true" z="100"
/>
</objects>
@@ -1,106 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<sprites>
<sprite name="goldPanel">
<!-- (currently this is all a hack - need proper textures) -->
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 -6 100% 0"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 100%+5 100% 100%"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="100% 0 100%+4 100%"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="-4 0 0 100%"
/>
<image
texture="global/tile/sandstone.dds"
texture_size="0 0 128 128"
/>
</sprite>
<sprite name="goldPanelFrilly">
<!-- (currently this is all a hack - need proper textures) -->
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 -6 100% 0"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 100%+5 100% 100%"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="100% 0 100%+4 100%"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="-4 0 0 100%"
/>
<image
texture="global/titlebar/left_gold_fern.dds"
texture_size="0 0 64 32"
size="-48 50%-16 0 50%+16"
/>
<image
texture="global/titlebar/right_gold_fern.dds"
texture_size="-16 0 48 32"
size="100% 50%-16 100%+48 50%+16"
/>
<image
texture="global/tile/sandstone.dds"
texture_size="0 0 128 128"
/>
</sprite>
<sprite name="selectionDetailsIconOutline">
<image backcolor="blue"/>
</sprite>
<sprite name="selectionDetailsHealthBackground">
<image backcolor="red"/>
</sprite>
<sprite name="selectionDetailsHealthForeground">
<image backcolor="green"/>
</sprite>
<sprite name="selectionDetailsStaminaBackground">
<image backcolor="black"/>
</sprite>
<sprite name="selectionDetailsStaminaForeground">
<image backcolor="blue"/>
</sprite>
<sprite name="bandbox">
<image backcolor="black" size="0 0 100% 1"/>
<image backcolor="black" size="100%-1 0 100% 100%"/>
<image backcolor="black" size="0 100%-1 100% 100%"/>
<image backcolor="black" size="0 0 1 100%"/>
<image backcolor="white" size="1 1 100%-1 2"/>
<image backcolor="white" size="100%-2 1 100%-1 100%-1"/>
<image backcolor="white" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="white" size="1 1 2 100%-1"/>
</sprite>
<sprite name="devCommandsBackground">
<image backcolor="0 0 0 85"/>
</sprite>
</sprites>
<?xml version="1.0" encoding="utf-8"?>
<sprites>
<sprite name="goldPanel">
<!-- (currently this is all a hack - need proper textures) -->
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 -6 100% 0"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 100%+5 100% 100%"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="-4 -4 0 100%+4"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="100% 0%-4 100%+4 100%+4"
/>
<image
texture="global/tile/sandstone.dds"
texture_size="0 0 128 128"
/>
</sprite>
<sprite name="goldPanelFrilly">
<!-- (currently this is all a hack - need proper textures) -->
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 -6 100% 0"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
texture_size="0 0 64 32"
size="0 100%+5 100% 100%"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="-4 -4 0 100%+4"
/>
<image
texture="global/border/corner_bronze.dds"
texture_size="0 0 16 100%"
size="100% 0%-4 100%+4 100%+4"
/>
<image
texture="global/titlebar/left_gold_fern.dds"
texture_size="0 0 64 32"
size="-48 50%-16 0 50%+16"
/>
<image
texture="global/titlebar/right_gold_fern.dds"
texture_size="-16 0 48 32"
size="100% 50%-16 100%+48 50%+16"
/>
<image
texture="global/tile/sandstone.dds"
texture_size="0 0 128 128"
/>
</sprite>
<sprite name="frilly">
<!-- (currently this is all a hack - need proper textures) -->
<image
texture="global/titlebar/left_gold_fern.dds"
texture_size="0 0 64 32"
size="-48 50%-16 0 50%+16"
/>
<image
texture="global/titlebar/right_gold_fern.dds"
texture_size="-16 0 48 32"
size="100% 50%-16 100%+48 50%+16"
/>
</sprite>
<sprite name="selectionDetailsIconOutline">
<image backcolor="blue"/>
</sprite>
<sprite name="selectionDetailsHealthBackground">
<image backcolor="red"/>
</sprite>
<sprite name="selectionDetailsHealthForeground">
<image backcolor="green"/>
</sprite>
<sprite name="selectionDetailsStaminaBackground">
<image backcolor="black"/>
</sprite>
<sprite name="selectionDetailsStaminaForeground">
<image backcolor="blue"/>
</sprite>
<sprite name="bandbox">
<image backcolor="black" size="0 0 100% 1"/>
<image backcolor="black" size="100%-1 0 100% 100%"/>
<image backcolor="black" size="0 100%-1 100% 100%"/>
<image backcolor="black" size="0 0 1 100%"/>
<image backcolor="white" size="1 1 100%-1 2"/>
<image backcolor="white" size="100%-2 1 100%-1 100%-1"/>
<image backcolor="white" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="white" size="1 1 2 100%-1"/>
</sprite>
<sprite name="primaryGroupHighlight">
<image backcolor="0 255 0 85"/>
</sprite>
<sprite name="devCommandsBackground">
<image backcolor="0 0 0 85"/>
</sprite>
</sprites>
@@ -1,65 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<styles>
<style name="goldPanel"
sprite="goldPanel"
buffer_zone="4"
text_align="left"
text_valign="top"
/>
<style name="goldPanelFrilly"
sprite="goldPanelFrilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
<style name="resourceIcon"
sprite="snIconSheetResource"
ghost="true"
/>
<style name="resourceText"
textcolor="black"
font="serif-bold-14"
ghost="true"
/>
<style name="resourceCounter"
tooltip_style="snToolTip"
/>
<style name="selectionDetailsIconOutline"
sprite="selectionDetailsIconOutline"
/>
<style name="iconButton"
sprite="snIconPortrait"
sprite_over="snIconPortraitOver"
sprite_disabled="snIconPortraitDisabled"
tooltip_style="snToolTipBottom"
/>
<style name="iconButtonCount"
textcolor="255 255 255"
font="serif-9"
text_align="right"
text_valign="top"
buffer_zone="4"
/>
<style name="iconButtonProgress"
textcolor="255 255 255"
font="serif-stroke-14"
text_align="center"
text_valign="center"
/>
<style name="devCommandsText"
font="sans-10"
textcolor="255 255 255"
text_align="right"
/>
</styles>
<?xml version="1.0" encoding="utf-8"?>
<styles>
<style name="goldPanel"
sprite="goldPanel"
buffer_zone="4"
text_align="left"
text_valign="top"
/>
<style name="goldPanelFrilly"
sprite="goldPanelFrilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
<style name="frilly"
sprite="frilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
<style name="resourceIcon"
sprite="snIconSheetResource"
ghost="true"
/>
<style name="resourceText"
textcolor="black"
font="serif-bold-14"
ghost="true"
/>
<style name="resourceCounter"
tooltip_style="snToolTip"
/>
<style name="selectionDetailsIconOutline"
sprite="selectionDetailsIconOutline"
/>
<style name="iconButton"
sprite="snIconPortrait"
sprite_over="snIconPortraitOver"
sprite_disabled="snIconPortraitDisabled"
tooltip_style="snToolTipBottom"
/>
<style name="iconButtonCount"
textcolor="255 255 255"
font="serif-9"
text_align="right"
text_valign="top"
buffer_zone="4"
/>
<style name="iconButtonProgress"
textcolor="255 255 255"
font="serif-stroke-14"
text_align="center"
text_valign="center"
/>
<style name="groupIconsText"
font="mono-stroke-10"
textcolor="255 255 255"
text_align="left"
text_valign="bottom"
/>
<style name="devCommandsText"
font="sans-10"
textcolor="255 255 255"
text_align="right"
/>
<style name="settingsText"
font="serif-16"
textcolor="0 0 0"
text_align="right"
text_valign="center"
/>
<style name="rightAlignedText"
textcolor="255 255 255"
text_align="right"
text_valign="top"
/>
<style name="centeredText"
textcolor="0 0 0"
text_align="center"
text_valign="center"
/>
<style name="largeBoldCenteredText"
font="serif-bold-18"
textcolor="0 0 0"
text_align="center"
text_valign="center"
/>
</styles>