mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 13:23:56 -07:00
# Rough first version of GUI redesign
Minor GUI engine cleanups This was SVN commit r7289.
This commit is contained in:
parent
0e8698d652
commit
c399dc277e
9 changed files with 254 additions and 58 deletions
|
|
@ -4,6 +4,8 @@
|
|||
<include>common/styles.xml</include>
|
||||
<include>common/sprite1.xml</include>
|
||||
<include>common/init.xml</include>
|
||||
<include>session_new/sprites.xml</include>
|
||||
<include>session_new/styles.xml</include>
|
||||
<include>session_new/session.xml</include>
|
||||
<include>common/global.xml</include>
|
||||
</page>
|
||||
|
|
|
|||
|
|
@ -7,47 +7,61 @@ function onSimulationUpdate()
|
|||
{
|
||||
updateDebug();
|
||||
|
||||
updateBuildButton();
|
||||
updateUnitDisplay();
|
||||
}
|
||||
|
||||
function updateDebug()
|
||||
{
|
||||
var debug = getGUIObjectByName("debug");
|
||||
var simState = Engine.GuiInterfaceCall("GetSimulationState");
|
||||
var text = "Simulation:\n" + uneval(simState);
|
||||
text += "\n\n";
|
||||
for (var ent in g_Selection)
|
||||
{
|
||||
var entState = Engine.GuiInterfaceCall("GetEntityState", ent);
|
||||
text += "Entity "+ent+":\n" + uneval(entState);
|
||||
text += "\n\n";
|
||||
text += "Template:\n" + uneval(Engine.GuiInterfaceCall("GetTemplateData", entState.template));
|
||||
}
|
||||
var text = uneval(simState);
|
||||
debug.caption = text;
|
||||
}
|
||||
|
||||
function updateBuildButton()
|
||||
function updateUnitDisplay()
|
||||
{
|
||||
var detailsPanel = getGUIObjectByName("unitDetails");
|
||||
var commandsPanel = getGUIObjectByName("unitCommands");
|
||||
|
||||
var selection = getEntitySelection();
|
||||
if (selection.length)
|
||||
if (selection.length == 0)
|
||||
{
|
||||
var entity = Engine.GuiInterfaceCall("GetEntityState", selection[0]);
|
||||
if (entity.buildEntities && entity.buildEntities.length)
|
||||
{
|
||||
var ent = entity.buildEntities[0];
|
||||
var template = Engine.GuiInterfaceCall("GetTemplateData", ent);
|
||||
|
||||
var name;
|
||||
if (template.name.specific && template.name.generic)
|
||||
name = template.name.specific + " (" + template.name.generic + ")";
|
||||
else
|
||||
name = template.name.specific || template.name.generic;
|
||||
|
||||
getGUIObjectByName("testBuild").caption = "Construct "+name;
|
||||
getGUIObjectByName("testBuild").onpress = function() { testBuild(ent) };
|
||||
getGUIObjectByName("testBuild").hidden = false;
|
||||
return;
|
||||
}
|
||||
detailsPanel.hidden = true;
|
||||
commandsPanel.hidden = true;
|
||||
return;
|
||||
}
|
||||
getGUIObjectByName("testBuild").hidden = true;
|
||||
|
||||
var entState = Engine.GuiInterfaceCall("GetEntityState", selection[0]);
|
||||
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
|
||||
|
||||
detailsPanel.hidden = false;
|
||||
detailsPanel.caption = uneval(entState)+"\n\n"+uneval(template);
|
||||
|
||||
commandsPanel.hidden = false;
|
||||
|
||||
var i = 0;
|
||||
for each (var build in entState.buildEntities)
|
||||
{
|
||||
var button = getGUIObjectByName("cButton"+i);
|
||||
var icon = getGUIObjectByName("cIcon"+i);
|
||||
|
||||
var template = Engine.GuiInterfaceCall("GetTemplateData", build);
|
||||
|
||||
var name;
|
||||
if (template.name.specific && template.name.generic)
|
||||
name = template.name.specific + " (" + template.name.generic + ")";
|
||||
else
|
||||
name = template.name.specific || template.name.generic || "???";
|
||||
|
||||
button.hidden = false;
|
||||
button.tooltip = "Construct " + name;
|
||||
button.onpress = (function(b) { return function() { testBuild(b) } })(build);
|
||||
// (need nested functions to get the closure right)
|
||||
|
||||
icon.sprite = "snPortraitSheetHele";
|
||||
icon.cell_id = template.name.icon_cell;
|
||||
++i;
|
||||
}
|
||||
for (; i < 8; ++i)
|
||||
getGUIObjectByName("cButton"+i).hidden = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,15 +39,6 @@
|
|||
<action on="Press">
|
||||
this.hidden = !this.hidden;
|
||||
</action>
|
||||
|
||||
<object name="testBuild"
|
||||
type="button"
|
||||
style="wheatButton"
|
||||
size="64 100%-96 320 100%-64"
|
||||
hidden="true"
|
||||
>
|
||||
Construct thing
|
||||
</object>
|
||||
|
||||
<!-- Exit hotkey -->
|
||||
<object name="leave" hotkey="leave">
|
||||
|
|
@ -56,24 +47,105 @@
|
|||
["Yes", "No!"], [confirmLeave, null]);
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
|
||||
<!-- Debug text -->
|
||||
<object name="debug"
|
||||
type="text"
|
||||
size="0 0 50% 100%"
|
||||
ghost="true"
|
||||
textcolor="yellow"
|
||||
font="console"
|
||||
>
|
||||
[default debug text]
|
||||
</object>
|
||||
|
||||
<!-- Bottom-left selected-unit details panel -->
|
||||
<object name="unitDetails"
|
||||
style="goldPanel"
|
||||
size="0 100%-250 300 100%"
|
||||
type="text"
|
||||
hidden="true"
|
||||
>
|
||||
[unit details]
|
||||
</object>
|
||||
|
||||
<!-- Bottom-middle selected-unit commands panel -->
|
||||
<object name="unitCommands"
|
||||
size="350 100%-204 100%-300 100%"
|
||||
>
|
||||
|
||||
<object name="unitConstructionPanel"
|
||||
style="goldPanelFrilly"
|
||||
size="0 0 100% 56"
|
||||
type="image"
|
||||
>
|
||||
<object size="50%-159 10 50%+159 47">
|
||||
|
||||
<!-- TODO: need a better way to do this. Perhaps something like
|
||||
<object name="buttons" type="repeater" count="8" sizedelta="40 0 0 0">
|
||||
<object type="button" .../>
|
||||
</object>
|
||||
where a script can change the count dynamically?
|
||||
-->
|
||||
<object name="cButton0" style="iconButton" type="button" size="0 0 37 37">
|
||||
<object name="cIcon0" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
<object name="cButton1" style="iconButton" type="button" size="40 0 77 37">
|
||||
<object name="cIcon1" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
<object name="cButton2" style="iconButton" type="button" size="80 0 117 37">
|
||||
<object name="cIcon2" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
<object name="cButton3" style="iconButton" type="button" size="120 0 157 37">
|
||||
<object name="cIcon3" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
<object name="cButton4" style="iconButton" type="button" size="160 0 197 37">
|
||||
<object name="cIcon4" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
<object name="cButton5" style="iconButton" type="button" size="200 0 237 37">
|
||||
<object name="cIcon5" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
<object name="cButton6" style="iconButton" type="button" size="240 0 277 37">
|
||||
<object name="cIcon6" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
<object name="cButton7" style="iconButton" type="button" size="280 0 317 37">
|
||||
<object name="cIcon7" type="image" ghost="true" size="3 3 35 35"/>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
</object>
|
||||
|
||||
<object name="unitFormationPanel"
|
||||
style="goldPanelFrilly"
|
||||
size="0 72 100% 128"
|
||||
type="text"
|
||||
>
|
||||
[formation commands]
|
||||
</object>
|
||||
|
||||
<object name="unitStancePanel"
|
||||
style="goldPanelFrilly"
|
||||
size="0 144 100% 200"
|
||||
type="text"
|
||||
>
|
||||
[stance commands]
|
||||
</object>
|
||||
|
||||
</object>
|
||||
|
||||
<!-- Minimap -->
|
||||
<object name="minimap">
|
||||
<object style="goldPanel"
|
||||
size="100%-246 100%-246 100% 100%"
|
||||
type="image"
|
||||
/>
|
||||
<object name="minimapDisplay"
|
||||
style="snObject"
|
||||
type="minimap"
|
||||
size="100%-138 100%-138 100%-6 100%-6"
|
||||
/>
|
||||
|
||||
<object name="minimapBorder"
|
||||
style="snMiniMapBorder"
|
||||
type="image"
|
||||
size="100%-172 100%-172 100% 100%"
|
||||
size="100%-206 100%-206 100%-6 100%-6"
|
||||
/>
|
||||
</object>
|
||||
|
||||
<!-- Debug text -->
|
||||
<object name="debug" type="text" size="0 0 50% 100%" ghost="true" textcolor="yellow" font="console">[default debug text]</object>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
|
|
|
|||
71
binaries/data/mods/public/gui/session_new/sprites.xml
Normal file
71
binaries/data/mods/public/gui/session_new/sprites.xml
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?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>
|
||||
|
||||
</sprites>
|
||||
|
||||
28
binaries/data/mods/public/gui/session_new/styles.xml
Normal file
28
binaries/data/mods/public/gui/session_new/styles.xml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?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="iconButton"
|
||||
sprite="snIconPortrait"
|
||||
sprite_over="snIconPortraitOver"
|
||||
sprite_disabled="snIconPortraitDisabled"
|
||||
text_align="right"
|
||||
textcolor="255 255 255"
|
||||
tooltip_style="snToolTip"
|
||||
tooltip="(TBA)"
|
||||
/>
|
||||
|
||||
</styles>
|
||||
|
|
@ -58,7 +58,8 @@ GuiInterface.prototype.GetTemplateData = function(player, name)
|
|||
{
|
||||
ret.name = {
|
||||
"specific": template.Identity.SpecificName,
|
||||
"generic": template.Identity.GenericName
|
||||
"generic": template.Identity.GenericName,
|
||||
"icon_cell": template.Identity.IconCell
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -341,6 +341,18 @@ PSRETURN GUI<T>::GetSetting(const IGUIObject *pObject, const CStr& Setting, T &V
|
|||
return ret;
|
||||
}
|
||||
|
||||
// Helper function for SetSetting
|
||||
template <typename T>
|
||||
bool IsBoolTrue(const T&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
template <>
|
||||
bool IsBoolTrue<bool>(const bool& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
PSRETURN GUI<T>::SetSetting(IGUIObject *pObject, const CStr& Setting,
|
||||
const T &Value, const bool& SkipMessage)
|
||||
|
|
@ -375,8 +387,8 @@ PSRETURN GUI<T>::SetSetting(IGUIObject *pObject, const CStr& Setting,
|
|||
if (Setting == "hidden")
|
||||
{
|
||||
// Hiding an object requires us to reset it and all children
|
||||
QueryResetting(pObject);
|
||||
//RecurseObject(0, pObject, IGUIObject::ResetStates);
|
||||
if (IsBoolTrue(Value))
|
||||
QueryResetting(pObject);
|
||||
}
|
||||
|
||||
if (!SkipMessage)
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ public:
|
|||
const CGUISpriteInstance& prim,
|
||||
const CGUISpriteInstance& sec)
|
||||
{
|
||||
// CStr() == empty string, null
|
||||
return (prim.IsEmpty() ? sec : prim);
|
||||
}
|
||||
|
||||
|
|
@ -223,14 +222,14 @@ public:
|
|||
* Sets a value by setting and object name using a real
|
||||
* datatype as input.
|
||||
*
|
||||
* This is just a wrapper for _mem_ParseString() which really
|
||||
* This is just a wrapper for __ParseString() which really
|
||||
* works the magic.
|
||||
*
|
||||
* @param Value The value in string form, like "0 0 100% 100%"
|
||||
* @param tOutput Parsed value of type T
|
||||
* @return True at success.
|
||||
*
|
||||
* @see _mem_ParseString()
|
||||
* @see __ParseString()
|
||||
*/
|
||||
static bool ParseString(const CStr& Value, T &tOutput)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,9 +64,6 @@ IGUIObject::IGUIObject() :
|
|||
|
||||
for (int i=0; i<6; i++)
|
||||
m_LastClickTime[i]=0;
|
||||
bool hidden=true;
|
||||
|
||||
GUI<bool>::GetSetting(this, "hidden", hidden);
|
||||
}
|
||||
|
||||
IGUIObject::~IGUIObject()
|
||||
|
|
|
|||
Loading…
Reference in a new issue