mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-09 17:55:43 +00:00
* Added player colour to player name, using Matei's new getColour() function.
* Used the actual player names instead of sharing the profile name (though the default names are a bit lengthy and extend off the UI; need to figure out how to change those during game setup using each player's profile name). * Fixed health/stamina bug. * Added an onMouseEnter() event for tabs at Matei's suggestion (so the tabs will open simply by getting the cursor in proximity, instead of needing two clicks). This was SVN commit r3592.
This commit is contained in:
@@ -22,7 +22,7 @@ function startMap (mapName, losSetting, openWindow)
|
||||
// Set up game
|
||||
g_GameAttributes.mapFile = mapName;
|
||||
g_GameAttributes.losSetting = losSetting;
|
||||
|
||||
|
||||
// Close setup window
|
||||
closeMainMenuSubWindow (openWindow);
|
||||
|
||||
|
||||
@@ -165,38 +165,43 @@ console.write ("2nd: " + tabCounter + " " + tab + " " + type + " " + cellSheet +
|
||||
// Set tab tooltip.
|
||||
tooltip = cellGroup[cellSheet][tab].name;
|
||||
tooltip += " " + cellSheet;
|
||||
|
||||
// Set tab function.
|
||||
tabObject.onPress = function (event)
|
||||
{
|
||||
}
|
||||
break;
|
||||
case "pick":
|
||||
// Set tab tooltip.
|
||||
tooltip = cellSheet;
|
||||
tooltip += " List\nCurrent " + cellSheet + ": " + cellGroup[cellSheet][tab].name;
|
||||
|
||||
// Set tab function.
|
||||
tabObject.onPress = function (event)
|
||||
{
|
||||
// Click the tab button to toggle visibility of its list.
|
||||
guiToggle ( "snStatusPaneCommandGroup" + this.name.substring (this.name.lastIndexOf ("d")+1, this.name.lastIndexOf ("_")) );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Set tab tooltip.
|
||||
tooltip = cellGroup[cellSheet][tab].name;
|
||||
tooltip += " " + cellSheet;
|
||||
break;
|
||||
}
|
||||
tabObject.tooltip = tooltip;
|
||||
|
||||
// Set tab function.
|
||||
switch (type)
|
||||
{
|
||||
case "command":
|
||||
// An array of actions for the command "tabs" can be triggered by clicking the individual commands. We'll set them here.
|
||||
tabObject.onPress = function (event)
|
||||
{
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Set tab function when user moves mouse over tab.
|
||||
tabObject.onMouseEnter = function (event)
|
||||
{
|
||||
// Click the tab button to toggle visibility of its list.
|
||||
guiToggle ( "snStatusPaneCommandGroup" + this.name.substring (this.name.lastIndexOf ("d")+1, this.name.lastIndexOf ("_")) );
|
||||
}
|
||||
// Set tab function when user clicks tab.
|
||||
tabObject.onPress = function (event)
|
||||
{
|
||||
// Click the tab button to toggle visibility of its list.
|
||||
guiToggle ( "snStatusPaneCommandGroup" + this.name.substring (this.name.lastIndexOf ("d")+1, this.name.lastIndexOf ("_")) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
tabObject.tooltip = tooltip;
|
||||
|
||||
// Get group.
|
||||
groupObject = getGUIObjectByName ("snStatusPaneCommand" + "Group" + tabCounter);
|
||||
|
||||
@@ -22,51 +22,50 @@ function refreshStatusPane()
|
||||
}
|
||||
|
||||
// Update hitpoint bar.
|
||||
if ( (shouldUpdateStat ( "traits.health.max" ) || shouldUpdateStat ( "traits.health.curr" )) )
|
||||
if ( selectionChanged || shouldUpdateStat ( "traits.health.max" ) || shouldUpdateStat ( "traits.health.curr" ) )
|
||||
{
|
||||
guiObject = getGUIObjectByName ("snStatusPaneHealthBar");
|
||||
barObject = getGUIObjectByName ("snStatusPaneHealthBar");
|
||||
textObject = getGUIObjectByName ("snStatusPaneHealthBarText");
|
||||
if (selection[0].traits.health.max && selection[0].traits.health.max != 0)
|
||||
{
|
||||
guiObject.caption = (selection[0].traits.health.curr * 100) / selection[0].traits.health.max;
|
||||
guiObject.hidden = false;
|
||||
barObject.caption = (selection[0].traits.health.curr * 100) / selection[0].traits.health.max;
|
||||
barObject.hidden = false;
|
||||
textObject.caption = "[font=verdana8][color=white]" + selection[0].traits.health.curr + "[/color][/font]";
|
||||
}
|
||||
else
|
||||
{
|
||||
guiObject.hidden = true;
|
||||
barObject.hidden = true;
|
||||
textObject.caption = "";
|
||||
}
|
||||
// Update text.
|
||||
getGUIObjectByName ("snStatusPaneHealthBarText").caption =
|
||||
"[font=verdana8][color=white]" + selection[0].traits.health.curr + "[/color][/font]";
|
||||
}
|
||||
|
||||
// Update stamina bar.
|
||||
if ( (shouldUpdateStat ( "traits.stamina.max" ) || shouldUpdateStat ( "traits.stamina.curr" )) )
|
||||
if ( selectionChanged || shouldUpdateStat ( "traits.stamina.max" ) || shouldUpdateStat ( "traits.stamina.curr" ) )
|
||||
{
|
||||
guiObject = getGUIObjectByName ("snStatusPaneStaminaBar");
|
||||
barObject = getGUIObjectByName ("snStatusPaneStaminaBar");
|
||||
textObject = getGUIObjectByName ("snStatusPaneStaminaBarText");
|
||||
if (selection[0].traits.stamina.max && selection[0].traits.stamina.max != 0)
|
||||
{
|
||||
guiObject.caption = (selection[0].traits.stamina.curr * 100) / selection[0].traits.stamina.max;
|
||||
guiObject.hidden = false;
|
||||
barObject.caption = (selection[0].traits.stamina.curr * 100) / selection[0].traits.stamina.max;
|
||||
barObject.hidden = false;
|
||||
textObject.caption = "[font=verdana8][color=white]" + selection[0].traits.stamina.curr + "[/color][/font]";
|
||||
}
|
||||
else
|
||||
{
|
||||
guiObject.hidden = true;
|
||||
barObject.hidden = true;
|
||||
textObject.caption = "";
|
||||
}
|
||||
// Update text.
|
||||
getGUIObjectByName ("snStatusPaneStaminaBarText").caption =
|
||||
"[font=verdana8][color=white]" + selection[0].traits.stamina.curr + "[/color][/font]";
|
||||
}
|
||||
|
||||
// Update unit text panel.
|
||||
if ( shouldUpdateStat ("player") || shouldUpdateStat ( "traits.id.civ" ) || shouldUpdateStat ( "traits.id.generic" ) || shouldUpdateStat ( "traits.id.specific" ) )
|
||||
{
|
||||
textCaption = "";
|
||||
// (Is there some way to grab the player colour RGB values? It'd be good if we could put the player name in player colour.)
|
||||
textCaption += "[font=verdana10][color=white]" + getCurrItemValue ("pgProfileName") + "[/color][/font]\n";
|
||||
textCaption += '[font=verdana10][color="' + Math.round(selection[0].player.getColour().r*255) + ' ' + Math.round(selection[0].player.getColour().g*255) + ' ' + Math.round(selection[0].player.getColour().b*255) + '"]' + selection[0].player.name + '[/color][/font]\n';
|
||||
textCaption += "[font=verdana10][color=white]" + selection[0].traits.id.civ + "[/color][/font]\n";
|
||||
textCaption += "[font=verdana10][color=white]" + selection[0].traits.id.specific + "[/color][/font]\n";
|
||||
textCaption += "[font=optimus12][color=gold]" + selection[0].traits.id.generic + "[/color][/font]\n";
|
||||
|
||||
textCaption += "[font=optimus12][color=gold]" + selection[0].traits.id.generic + "[/color][/font]";
|
||||
console.write (textCaption);
|
||||
getGUIObjectByName ("snStatusPaneText").caption = textCaption;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user