mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 06:13:55 -07:00
Allow ingame menu to reverse, add sounds to all menu buttons, and some organizing and cleanup
This was SVN commit r10194.
This commit is contained in:
parent
1a76c3b848
commit
7a7ebaa983
8 changed files with 862 additions and 745 deletions
|
|
@ -17,6 +17,8 @@ const MAIN_MENU = "main_menu";
|
|||
const DEFEAT_CUE = "gen_loss_cue";
|
||||
const DEFEAT_MUSIC = "gen_loss_track";
|
||||
const VICTORY_MUSIC = "win_1";
|
||||
//const AMBIENT_SOUND = "audio/ambient/dayscape/day_temperate_gen_03.ogg";
|
||||
const BUTTON_SOUND = "audio/interface/ui/ui_button_longclick.ogg";
|
||||
|
||||
// ====================================================================
|
||||
|
||||
|
|
@ -42,11 +44,15 @@ const VICTORY_MUSIC = "win_1";
|
|||
function newRandomSound(soundType, soundSubType, soundPrePath)
|
||||
{
|
||||
// Return a random audio file by category, to be assigned to a handle.
|
||||
var randomSoundPath;
|
||||
|
||||
switch (soundType)
|
||||
{
|
||||
case "music":
|
||||
var randomSoundPath = "audio/music/"
|
||||
randomSoundPath = "audio/music/"
|
||||
break;
|
||||
case "ambient":
|
||||
randomSoundPath = "audio/ambient/" + soundPrePath + "/";
|
||||
break;
|
||||
case "effect":
|
||||
randomSoundPath = soundPrePath + "/";
|
||||
|
|
@ -161,12 +167,18 @@ function getRandomBattleTrack()
|
|||
|
||||
function playMainMenuMusic()
|
||||
{
|
||||
if (global.curr_music)
|
||||
if (global.curr_music)
|
||||
switchMusic(MAIN_MENU, 0.0, true);
|
||||
else
|
||||
playMusic(MAIN_MENU, 0.0, true);
|
||||
}
|
||||
|
||||
function playButtonSound()
|
||||
{
|
||||
var buttonSound = new Sound(BUTTON_SOUND);
|
||||
buttonSound.play();
|
||||
}
|
||||
|
||||
function stopMainMenuMusic()
|
||||
{
|
||||
if (global.main_menu_music)
|
||||
|
|
@ -192,6 +204,16 @@ function startSessionSounds(civMusic)
|
|||
playRandomCivMusic();
|
||||
}
|
||||
|
||||
function startMusic()
|
||||
{
|
||||
console.write(getRandomPeaceTrack());
|
||||
|
||||
|
||||
console.write(global.curr_music);
|
||||
playRandomCivMusic();
|
||||
console.write(global.curr_music);
|
||||
}
|
||||
|
||||
function playRandomCivMusic()
|
||||
{
|
||||
global.curr_music = new Sound(getRandomPeaceTrack());
|
||||
|
|
@ -204,7 +226,10 @@ function playRandomCivMusic()
|
|||
|
||||
function playAmbientSounds()
|
||||
{
|
||||
global.curr_ambient = new Sound("audio/ambient/dayscape/day_temperate_gen_03.ogg");
|
||||
// Seem to need the underscore at the end of "temperate" to avoid crash
|
||||
// (Might be caused by trying to randomly load day_temperate.xml)
|
||||
global.curr_ambient = newRandomSound("ambient", "temperate_", "dayscape");
|
||||
console.write(global.curr_ambient);
|
||||
if (global.curr_ambient)
|
||||
{
|
||||
global.curr_ambient.loop();
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ function init()
|
|||
|
||||
userReportEnabledText = getGUIObjectByName("userReportEnabledText").caption;
|
||||
|
||||
// initialize currentSubmenuType with placeholder to avoid null when switching
|
||||
currentSubmenuType = "submenuSinglePlayer";
|
||||
// initialize currentSubmenuType with placeholder to avoid null when switching
|
||||
currentSubmenuType = "submenuSinglePlayer";
|
||||
}
|
||||
|
||||
var t0 = new Date;
|
||||
|
|
@ -82,11 +82,11 @@ function formatUserReportStatus(status)
|
|||
|
||||
function onTick()
|
||||
{
|
||||
// Animate backgrounds
|
||||
// Animate backgrounds
|
||||
scrollBackgrounds();
|
||||
|
||||
// Animate submenu
|
||||
updateMenuPosition();
|
||||
// Animate submenu
|
||||
updateMenuPosition();
|
||||
|
||||
if (Engine.IsUserReportEnabled())
|
||||
{
|
||||
|
|
@ -112,81 +112,77 @@ function onTick()
|
|||
// Slide menu
|
||||
function updateMenuPosition()
|
||||
{
|
||||
var submenu = getGUIObjectByName("submenu");
|
||||
var submenu = getGUIObjectByName("submenu");
|
||||
|
||||
if (submenu.hidden == false)
|
||||
{
|
||||
// The offset is the increment or number of units/pixels to move
|
||||
// the menu. An offset of one is always accurate, but it is too
|
||||
// slow. The offset must divide into the travel distance evenly
|
||||
// in order for the menu to end up at the right spot. The travel
|
||||
// distance is the max-initial. The travel distance in this
|
||||
// example is 300-60 = 240. We choose an offset of 5 because it
|
||||
// divides into 240 evenly and provided the speed we wanted.
|
||||
var OFFSET = 10;
|
||||
if (submenu.hidden == false)
|
||||
{
|
||||
// The offset is the increment or number of units/pixels to move
|
||||
// the menu. An offset of one is always accurate, but it is too
|
||||
// slow. The offset must divide into the travel distance evenly
|
||||
// in order for the menu to end up at the right spot. The travel
|
||||
// distance is the max-initial. The travel distance in this
|
||||
// example is 300-60 = 240. We choose an offset of 5 because it
|
||||
// divides into 240 evenly and provided the speed we wanted.
|
||||
const OFFSET = 10;
|
||||
|
||||
if (submenu.size.left < getGUIObjectByName("mainMenu").size.right)
|
||||
{
|
||||
submenu.size = (submenu.size.left + OFFSET) + " " + submenu.size.top + " " + (submenu.size.right + OFFSET) + " " + submenu.size.bottom;
|
||||
}
|
||||
}
|
||||
if (submenu.size.left < getGUIObjectByName("mainMenu").size.right)
|
||||
{
|
||||
submenu.size = (submenu.size.left + OFFSET) + " " + submenu.size.top + " " + (submenu.size.right + OFFSET) + " " + submenu.size.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Opens the menu by revealing the screen which contains the menu
|
||||
function openMenu(newSubmenu, position, buttonHeight, numButtons)
|
||||
{
|
||||
var menuSound = new newRandomSound("effect", "arrowfly_", "audio/attack/weapon");
|
||||
if (menuSound)
|
||||
{
|
||||
menuSound.play(0);
|
||||
}
|
||||
// switch to new submenu type
|
||||
currentSubmenuType = newSubmenu;
|
||||
getGUIObjectByName(currentSubmenuType).hidden = false;
|
||||
|
||||
// switch to new submenu type
|
||||
currentSubmenuType = newSubmenu;
|
||||
getGUIObjectByName(currentSubmenuType).hidden = false;
|
||||
// set position of new submenu
|
||||
var submenu = getGUIObjectByName("submenu");
|
||||
var top = position - MARGIN;
|
||||
var bottom = position + ((buttonHeight + MARGIN) * numButtons);
|
||||
submenu.size = submenu.size.left + " " + top + " " + submenu.size.right + " " + bottom;
|
||||
|
||||
// set position of new submenu
|
||||
var submenu = getGUIObjectByName("submenu");
|
||||
var top = position - MARGIN;
|
||||
var bottom = position + ((buttonHeight + MARGIN) * numButtons);
|
||||
submenu.size = submenu.size.left + " " + top + " " + submenu.size.right + " " + bottom;
|
||||
// Blend in right border of main menu into the left border of the submenu
|
||||
blendSubmenuIntoMain(top, bottom);
|
||||
|
||||
// Blend in right border of main menu into the left border of the submenu
|
||||
blendSubmenuIntoMain(top, bottom);
|
||||
// Reveal submenu
|
||||
getGUIObjectByName("submenu").hidden = false;
|
||||
|
||||
// Reveal submenu
|
||||
getGUIObjectByName("submenu").hidden = false;
|
||||
|
||||
// prepare to hide the submenu when the user clicks on the background
|
||||
getGUIObjectByName("submenuScreen").hidden = false;
|
||||
// prepare to hide the submenu when the user clicks on the background
|
||||
getGUIObjectByName("submenuScreen").hidden = false;
|
||||
}
|
||||
|
||||
// Closes the menu and resets position
|
||||
function closeMenu()
|
||||
{
|
||||
// remove old submenu type
|
||||
getGUIObjectByName(currentSubmenuType).hidden = true;
|
||||
playButtonSound();
|
||||
|
||||
// hide submenu and reset position
|
||||
var submenu = getGUIObjectByName("submenu");
|
||||
submenu.hidden = true;
|
||||
submenu.size = getGUIObjectByName("mainMenu").size;
|
||||
// remove old submenu type
|
||||
getGUIObjectByName(currentSubmenuType).hidden = true;
|
||||
|
||||
// reset main menu panel right border
|
||||
getGUIObjectByName("MainMenuPanelRightBorderTop").size = "100%-2 0 100% 100%";
|
||||
// hide submenu and reset position
|
||||
var submenu = getGUIObjectByName("submenu");
|
||||
submenu.hidden = true;
|
||||
submenu.size = getGUIObjectByName("mainMenu").size;
|
||||
|
||||
// hide submenu screen
|
||||
getGUIObjectByName("submenuScreen").hidden = false;
|
||||
// reset main menu panel right border
|
||||
getGUIObjectByName("MainMenuPanelRightBorderTop").size = "100%-2 0 100% 100%";
|
||||
|
||||
// hide submenu screen
|
||||
getGUIObjectByName("submenuScreen").hidden = false;
|
||||
}
|
||||
|
||||
// Sizes right border on main menu panel to match the submenu
|
||||
function blendSubmenuIntoMain(topPosition, bottomPosition)
|
||||
{
|
||||
var topSprite = getGUIObjectByName("MainMenuPanelRightBorderTop");
|
||||
topSprite.size = "100%-2 0 100% " + (topPosition + MARGIN);
|
||||
var topSprite = getGUIObjectByName("MainMenuPanelRightBorderTop");
|
||||
topSprite.size = "100%-2 0 100% " + (topPosition + MARGIN);
|
||||
|
||||
var bottomSprite = getGUIObjectByName("MainMenuPanelRightBorderBottom");
|
||||
bottomSprite.size = "100%-2 " + (bottomPosition) + " 100% 100%";
|
||||
var bottomSprite = getGUIObjectByName("MainMenuPanelRightBorderBottom");
|
||||
bottomSprite.size = "100%-2 " + (bottomPosition) + " 100% 100%";
|
||||
}
|
||||
|
||||
// Reveals submenu
|
||||
|
|
@ -209,54 +205,54 @@ function closeMainMenuSubWindow (windowName)
|
|||
* FUNCTIONS BELOW DO NOT WORK YET
|
||||
*/
|
||||
|
||||
// Switch to a given options tab window.
|
||||
function openOptionsTab(tabName)
|
||||
{
|
||||
// Hide the other tabs.
|
||||
for (i = 1; i <= 3; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
var tmpName = "pgOptionsAudio";
|
||||
break;
|
||||
case 2:
|
||||
var tmpName = "pgOptionsVideo";
|
||||
break;
|
||||
case 3:
|
||||
var tmpName = "pgOptionsGame";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (tmpName != tabName)
|
||||
{
|
||||
getGUIObjectByName (tmpName + "Window").hidden = true;
|
||||
getGUIObjectByName (tmpName + "Button").enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Make given tab visible.
|
||||
getGUIObjectByName (tabName + "Window").hidden = false;
|
||||
getGUIObjectByName (tabName + "Button").enabled = false;
|
||||
}
|
||||
|
||||
// Move the credits up the screen.
|
||||
function updateCredits()
|
||||
{
|
||||
// If there are still credit lines to remove, remove them.
|
||||
if (getNumItems("pgCredits") > 0)
|
||||
removeItem ("pgCredits", 0);
|
||||
else
|
||||
{
|
||||
// When we've run out of credit,
|
||||
|
||||
// Stop the increment timer if it's still active.
|
||||
cancelInterval();
|
||||
|
||||
// Close the credits screen and return.
|
||||
closeMainMenuSubWindow ("pgCredits");
|
||||
guiUnHide ("pg");
|
||||
}
|
||||
}
|
||||
//// Switch to a given options tab window.
|
||||
//function openOptionsTab(tabName)
|
||||
//{
|
||||
// // Hide the other tabs.
|
||||
// for (i = 1; i <= 3; i++)
|
||||
// {
|
||||
// switch (i)
|
||||
// {
|
||||
// case 1:
|
||||
// var tmpName = "pgOptionsAudio";
|
||||
// break;
|
||||
// case 2:
|
||||
// var tmpName = "pgOptionsVideo";
|
||||
// break;
|
||||
// case 3:
|
||||
// var tmpName = "pgOptionsGame";
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// if (tmpName != tabName)
|
||||
// {
|
||||
// getGUIObjectByName (tmpName + "Window").hidden = true;
|
||||
// getGUIObjectByName (tmpName + "Button").enabled = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Make given tab visible.
|
||||
// getGUIObjectByName (tabName + "Window").hidden = false;
|
||||
// getGUIObjectByName (tabName + "Button").enabled = false;
|
||||
//}
|
||||
//
|
||||
//// Move the credits up the screen.
|
||||
//function updateCredits()
|
||||
//{
|
||||
// // If there are still credit lines to remove, remove them.
|
||||
// if (getNumItems("pgCredits") > 0)
|
||||
// removeItem ("pgCredits", 0);
|
||||
// else
|
||||
// {
|
||||
// // When we've run out of credit,
|
||||
//
|
||||
// // Stop the increment timer if it's still active.
|
||||
// cancelInterval();
|
||||
//
|
||||
// // Close the credits screen and return.
|
||||
// closeMainMenuSubWindow ("pgCredits");
|
||||
// guiUnHide ("pg");
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1094,22 +1094,8 @@ function performCommand(entity, commandName)
|
|||
{
|
||||
case "delete":
|
||||
var selection = g_Selection.toList();
|
||||
|
||||
if (selection.length > 0)
|
||||
{
|
||||
closeMenu();
|
||||
closeOpenDialogs();
|
||||
|
||||
var deleteFunction = function ()
|
||||
{
|
||||
Engine.PostNetworkCommand({"type": "delete-entities", "entities": selection});
|
||||
};
|
||||
|
||||
var btCaptions = ["Yes", "No"];
|
||||
var btCode = [deleteFunction, null];
|
||||
|
||||
messageBox(400, 200, "Destroy everything currently selected?", "Delete", 0, btCaptions, btCode);
|
||||
}
|
||||
openDeleteDialog(selection);
|
||||
break;
|
||||
case "garrison":
|
||||
inputState = INPUT_PRESELECTEDACTION;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
const PAUSE = "Pause";
|
||||
const RESUME = "Resume";
|
||||
|
||||
/*
|
||||
* MENU POSITION CONSTANTS
|
||||
*/
|
||||
|
|
@ -6,7 +9,7 @@
|
|||
const MARGIN = 4;
|
||||
|
||||
// Includes the main menu button
|
||||
const NUM_BUTTONS = 6;
|
||||
const NUM_BUTTONS = 5;
|
||||
|
||||
// Regular menu buttons
|
||||
const BUTTON_HEIGHT = 32;
|
||||
|
|
@ -14,74 +17,145 @@ const BUTTON_HEIGHT = 32;
|
|||
// The position where the bottom of the menu will end up (currently 164)
|
||||
const END_MENU_POSITION = (BUTTON_HEIGHT * NUM_BUTTONS) + MARGIN;
|
||||
|
||||
// Menu starting position - bottom
|
||||
// Menu starting position: bottom
|
||||
const MENU_BOTTOM = 36;
|
||||
|
||||
// Menu starting position - top
|
||||
// Menu starting position: top
|
||||
const MENU_TOP = MENU_BOTTOM - END_MENU_POSITION;
|
||||
|
||||
// Menu starting position - overall
|
||||
// Menu starting position: overall
|
||||
const INITIAL_MENU_POSITION = "100%-164 " + MENU_TOP + " 100% " + MENU_BOTTOM;
|
||||
|
||||
// The offset is the increment or number of units/pixels to move
|
||||
// the menu. An offset of one is always accurate, but it is too
|
||||
// slow. The offset must divide into the travel distance evenly
|
||||
// in order for the menu to end up at the right spot. The travel
|
||||
// distance is the max-initial. The travel distance in this
|
||||
// example is 164-36 = 128. We choose an offset of 16 because it
|
||||
// divides into 128 evenly and provided the speed we wanted.
|
||||
const OFFSET = 8;
|
||||
|
||||
var isMenuOpen = false;
|
||||
var menu;
|
||||
|
||||
// Ignore size defined in XML and set the actual menu size here
|
||||
function initMenuPosition()
|
||||
{
|
||||
menu = getGUIObjectByName("menu");
|
||||
menu.size = INITIAL_MENU_POSITION;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Overall Menu
|
||||
// =============================================================================
|
||||
//
|
||||
// Slide menu
|
||||
function updateMenuPosition()
|
||||
{
|
||||
if (getGUIObjectByName("menu").hidden == false)
|
||||
{
|
||||
var menu = getGUIObjectByName("menu");
|
||||
|
||||
// The offset is the increment or number of units/pixels to move
|
||||
// the menu. An offset of one is always accurate, but it is too
|
||||
// slow. The offset must divide into the travel distance evenly
|
||||
// in order for the menu to end up at the right spot. The travel
|
||||
// distance is the max-initial. The travel distance in this
|
||||
// example is 196-36 = 160. We choose an offset of 16 because it
|
||||
// divides into 160 evenly and provided the speed we wanted.
|
||||
var OFFSET = 16;
|
||||
|
||||
if (menu.size.bottom < END_MENU_POSITION)
|
||||
{
|
||||
menu.size = "100%-164 " + (menu.size.top + OFFSET) + " 100% " + (menu.size.bottom + OFFSET);
|
||||
}
|
||||
}
|
||||
if (isMenuOpen)
|
||||
{
|
||||
if (menu.size.bottom < END_MENU_POSITION)
|
||||
{
|
||||
menu.size = "100%-164 " + (menu.size.top + OFFSET) + " 100% " + (menu.size.bottom + OFFSET);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (menu.size.top > MENU_TOP)
|
||||
{
|
||||
menu.size = "100%-164 " + (menu.size.top - OFFSET) + " 100% " + (menu.size.bottom - OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Opens the menu by revealing the screen which contains the menu
|
||||
function openMenu()
|
||||
{
|
||||
var menuSound = new Sound("audio/interface/ui/ui_button_longclick.ogg");
|
||||
if (menuSound)
|
||||
{
|
||||
menuSound.play(0);
|
||||
}
|
||||
|
||||
getGUIObjectByName("menu").hidden = false;
|
||||
playButtonSound();
|
||||
isMenuOpen = true;
|
||||
}
|
||||
|
||||
// Closes the menu and resets position
|
||||
function closeMenu()
|
||||
{
|
||||
getGUIObjectByName("menu").hidden = true;
|
||||
getGUIObjectByName("menu").size = INITIAL_MENU_POSITION;
|
||||
playButtonSound();
|
||||
isMenuOpen = false;
|
||||
}
|
||||
|
||||
function openSettings()
|
||||
function toggleMenu()
|
||||
{
|
||||
closeMenu();
|
||||
closeChat();
|
||||
getGUIObjectByName("settingsDialogPanel").hidden = false;
|
||||
if (isMenuOpen == true)
|
||||
closeMenu();
|
||||
else
|
||||
openMenu();
|
||||
}
|
||||
|
||||
function closeSettings()
|
||||
// Menu buttons
|
||||
// =============================================================================
|
||||
function settingsMenuButton()
|
||||
{
|
||||
closeMenu();
|
||||
closeOpenDialogs();
|
||||
openSettings(true);
|
||||
}
|
||||
|
||||
function chatMenuButton()
|
||||
{
|
||||
closeMenu();
|
||||
closeOpenDialogs();
|
||||
openChat();
|
||||
}
|
||||
|
||||
function pauseMenuButton()
|
||||
{
|
||||
togglePause();
|
||||
}
|
||||
|
||||
function exitMenuButton()
|
||||
{
|
||||
closeMenu();
|
||||
closeOpenDialogs();
|
||||
pauseGame();
|
||||
var btCaptions = ["Yes", "No"];
|
||||
var btCode = [leaveGame, resumeGame];
|
||||
messageBox(400, 200, "Are you sure you want to quit?", "Confirmation", 0, btCaptions, btCode);
|
||||
}
|
||||
|
||||
function openDeleteDialog(selection)
|
||||
{
|
||||
closeMenu();
|
||||
closeOpenDialogs();
|
||||
|
||||
var deleteSelectedEntities = function ()
|
||||
{
|
||||
Engine.PostNetworkCommand({"type": "delete-entities", "entities": selection});
|
||||
};
|
||||
|
||||
var btCaptions = ["Yes", "No"];
|
||||
var btCode = [deleteSelectedEntities, resumeGame];
|
||||
|
||||
messageBox(400, 200, "Destroy everything currently selected?", "Delete", 0, btCaptions, btCode);
|
||||
}
|
||||
|
||||
// Menu functions
|
||||
// =============================================================================
|
||||
|
||||
function openSettings(pause)
|
||||
{
|
||||
getGUIObjectByName("settingsDialogPanel").hidden = false;
|
||||
if (pause)
|
||||
pauseGame();
|
||||
}
|
||||
|
||||
function closeSettings(resume)
|
||||
{
|
||||
getGUIObjectByName("settingsDialogPanel").hidden = true;
|
||||
if (resume)
|
||||
resumeGame();
|
||||
}
|
||||
|
||||
function openChat()
|
||||
{
|
||||
closeMenu();
|
||||
closeSettings();
|
||||
getGUIObjectByName("chatInput").focus(); // Grant focus to the input area
|
||||
getGUIObjectByName("chatDialogPanel").hidden = false;
|
||||
|
||||
|
|
@ -95,7 +169,7 @@ function closeChat()
|
|||
|
||||
function toggleChatWindow()
|
||||
{
|
||||
closeSettings();
|
||||
closeSettings();
|
||||
|
||||
var chatWindow = getGUIObjectByName("chatDialogPanel");
|
||||
var chatInput = getGUIObjectByName("chatInput");
|
||||
|
|
@ -108,23 +182,37 @@ function toggleChatWindow()
|
|||
chatWindow.hidden = !chatWindow.hidden;
|
||||
}
|
||||
|
||||
function pauseGame()
|
||||
{
|
||||
getGUIObjectByName("pauseButtonText").caption = RESUME;
|
||||
getGUIObjectByName("pauseOverlay").hidden = false;
|
||||
setPaused(true);
|
||||
}
|
||||
|
||||
function resumeGame()
|
||||
{
|
||||
getGUIObjectByName("pauseButtonText").caption = PAUSE;
|
||||
getGUIObjectByName("pauseOverlay").hidden = true;
|
||||
setPaused(false);
|
||||
}
|
||||
|
||||
function togglePause()
|
||||
{
|
||||
closeMenu();
|
||||
closeChat();
|
||||
closeSettings();
|
||||
closeMenu();
|
||||
closeOpenDialogs();
|
||||
|
||||
var pauseOverlay = getGUIObjectByName("pauseOverlay");
|
||||
|
||||
if (pauseOverlay.hidden)
|
||||
{
|
||||
getGUIObjectByName("pauseButtonText").caption = RESUME;
|
||||
setPaused(true);
|
||||
getGUIObjectByName("pauseButtonText").caption = "Unpause";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setPaused(false);
|
||||
getGUIObjectByName("pauseButtonText").caption = "Pause";
|
||||
getGUIObjectByName("pauseButtonText").caption = PAUSE;
|
||||
}
|
||||
|
||||
pauseOverlay.hidden = !pauseOverlay.hidden;
|
||||
|
|
@ -140,7 +228,7 @@ function toggleDeveloperOverlay()
|
|||
|
||||
function closeOpenDialogs()
|
||||
{
|
||||
closeMenu();
|
||||
closeChat();
|
||||
closeSettings();
|
||||
closeMenu();
|
||||
closeChat();
|
||||
closeSettings(false);
|
||||
}
|
||||
|
|
@ -71,6 +71,7 @@ function init(initData, hotloadData)
|
|||
g_CivData["gaia"] = { "Code": "gaia", "Name": "Gaia" };
|
||||
|
||||
getGUIObjectByName("civIcon").sprite = "stretched:"+g_CivData[g_Players[Engine.GetPlayerID()].civ].Emblem;
|
||||
initMenuPosition(); // set initial position
|
||||
|
||||
if (hotloadData)
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -12,6 +12,14 @@
|
|||
text_valign="center"
|
||||
/>
|
||||
|
||||
<style name="PauseMessageText"
|
||||
font="serif-bold-12"
|
||||
textcolor="white"
|
||||
text_align="center"
|
||||
text_valign="center"
|
||||
/>
|
||||
|
||||
|
||||
<style name="leftAlignedText"
|
||||
textcolor="white"
|
||||
text_align="left"
|
||||
|
|
|
|||
|
|
@ -96,12 +96,12 @@ function layoutButtonRow(rowNumber, guiName, buttonSideLength, buttonSpacer, sta
|
|||
if (button)
|
||||
{
|
||||
var size = button.size;
|
||||
|
||||
|
||||
size.left = buttonSpacer*colNumber;
|
||||
size.right = buttonSpacer*colNumber + buttonSideLength;
|
||||
size.top = buttonSpacer*rowNumber;
|
||||
size.bottom = buttonSpacer*rowNumber + buttonSideLength;
|
||||
|
||||
|
||||
button.size = size;
|
||||
colNumber++;
|
||||
}
|
||||
|
|
@ -109,50 +109,61 @@ function layoutButtonRow(rowNumber, guiName, buttonSideLength, buttonSpacer, sta
|
|||
}
|
||||
|
||||
// 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 numberOfItems = items.length;
|
||||
var selection = g_Selection.toList();
|
||||
var garrisonGroups = new EntityGroups();
|
||||
if (guiName == "Selection")
|
||||
|
||||
// Determine how many buttons there should be
|
||||
switch (guiName)
|
||||
{
|
||||
if (numberOfItems > 16)
|
||||
case SELECTION:
|
||||
if (numberOfItems > 16)
|
||||
numberOfItems = 16;
|
||||
}
|
||||
else if (guiName == "Formation")
|
||||
{
|
||||
if (numberOfItems > 16)
|
||||
numberOfItems = 16;
|
||||
}
|
||||
else if (guiName == "Stance")
|
||||
{
|
||||
if (numberOfItems > 5)
|
||||
break;
|
||||
|
||||
case QUEUE:
|
||||
if (numberOfItems > 16)
|
||||
numberOfItems = 16;
|
||||
break;
|
||||
|
||||
case GARRISON:
|
||||
if (numberOfItems > 16)
|
||||
numberOfItems = 16;
|
||||
//Group garrisoned units based on class
|
||||
garrisonGroups.add(unitEntState.garrisonHolder.entities);
|
||||
break;
|
||||
|
||||
case STANCE:
|
||||
if (numberOfItems > 5)
|
||||
numberOfItems = 5;
|
||||
}
|
||||
else if (guiName == "Queue")
|
||||
{
|
||||
if (numberOfItems > 16)
|
||||
numberOfItems = 16;
|
||||
}
|
||||
else if (guiName == "Garrison")
|
||||
{
|
||||
if (numberOfItems > 16)
|
||||
numberOfItems = 16;
|
||||
//Group garrisoned units based on class
|
||||
garrisonGroups.add(unitEntState.garrisonHolder.entities);
|
||||
}
|
||||
else if (guiName == "Command")
|
||||
{
|
||||
if (numberOfItems > 6)
|
||||
numberOfItems = 6;
|
||||
}
|
||||
else if (numberOfItems > 24)
|
||||
{
|
||||
numberOfItems = 24;
|
||||
case FORMATION:
|
||||
if (numberOfItems > 16)
|
||||
numberOfItems = 16;
|
||||
break;
|
||||
|
||||
case TRAINING:
|
||||
if (numberOfItems > 24)
|
||||
numberOfItems = 24;
|
||||
break;
|
||||
|
||||
case CONSTRUCTION:
|
||||
if (numberOfItems > 24)
|
||||
numberOfItems = 24;
|
||||
break;
|
||||
|
||||
case COMMAND:
|
||||
if (numberOfItems > 6)
|
||||
numberOfItems = 6;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Make buttons
|
||||
var i;
|
||||
for (i = 0; i < numberOfItems; i++)
|
||||
{
|
||||
|
|
@ -168,78 +179,78 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
|
|||
|
||||
switch (guiName)
|
||||
{
|
||||
case SELECTION:
|
||||
var name = getEntityName(template);
|
||||
var tooltip = name;
|
||||
var count = g_Selection.groups.getCount(item);
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : "");
|
||||
break;
|
||||
case SELECTION:
|
||||
var name = getEntityName(template);
|
||||
var tooltip = name;
|
||||
var count = g_Selection.groups.getCount(item);
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : "");
|
||||
break;
|
||||
|
||||
case QUEUE:
|
||||
var tooltip = getEntityName(template);
|
||||
var progress = Math.round(item.progress*100) + "%";
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (item.count > 1 ? item.count : "");
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
getGUIObjectByName("queueProgress").caption = (item.progress ? progress : "");
|
||||
var size = getGUIObjectByName("unit"+guiName+"ProgressSlider["+i+"]").size;
|
||||
size.top = Math.round(item.progress*40);
|
||||
getGUIObjectByName("unit"+guiName+"ProgressSlider["+i+"]").size = size;
|
||||
}
|
||||
break;
|
||||
case QUEUE:
|
||||
var tooltip = getEntityName(template);
|
||||
var progress = Math.round(item.progress*100) + "%";
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (item.count > 1 ? item.count : "");
|
||||
|
||||
case GARRISON:
|
||||
var name = getEntityName(template);
|
||||
var tooltip = "Unload " + getEntityName(template);
|
||||
var count = garrisonGroups.getCount(item);
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : "");
|
||||
break;
|
||||
if (i == 0)
|
||||
{
|
||||
getGUIObjectByName("queueProgress").caption = (item.progress ? progress : "");
|
||||
var size = getGUIObjectByName("unit"+guiName+"ProgressSlider["+i+"]").size;
|
||||
size.top = Math.round(item.progress*40);
|
||||
getGUIObjectByName("unit"+guiName+"ProgressSlider["+i+"]").size = size;
|
||||
}
|
||||
break;
|
||||
|
||||
case STANCE:
|
||||
case FORMATION:
|
||||
var tooltip = toTitleCase(item);
|
||||
break;
|
||||
case GARRISON:
|
||||
var name = getEntityName(template);
|
||||
var tooltip = "Unload " + getEntityName(template);
|
||||
var count = garrisonGroups.getCount(item);
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : "");
|
||||
break;
|
||||
|
||||
case TRAINING:
|
||||
var tooltip = getEntityNameWithGenericType(template);
|
||||
if (template.tooltip)
|
||||
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]";
|
||||
case STANCE:
|
||||
case FORMATION:
|
||||
var tooltip = toTitleCase(item);
|
||||
break;
|
||||
|
||||
tooltip += "\n" + getEntityCost(template);
|
||||
case TRAINING:
|
||||
var tooltip = getEntityNameWithGenericType(template);
|
||||
if (template.tooltip)
|
||||
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]";
|
||||
|
||||
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
|
||||
if (batchSize)
|
||||
{
|
||||
tooltip += "\n[font=\"serif-13\"]Training [font=\"serif-bold-13\"]" + batchSize + "[font=\"serif-13\"] units; " +
|
||||
"Shift-click to train [font=\"serif-bold-13\"]"+ (batchSize+batchIncrement) + "[font=\"serif-13\"] units[/font]";
|
||||
}
|
||||
break;
|
||||
tooltip += "\n" + getEntityCost(template);
|
||||
|
||||
case CONSTRUCTION:
|
||||
var tooltip = getEntityNameWithGenericType(template);
|
||||
if (template.tooltip)
|
||||
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + getPopulationBonus(template) + "[/font]";
|
||||
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
|
||||
if (batchSize)
|
||||
{
|
||||
tooltip += "\n[font=\"serif-13\"]Training [font=\"serif-bold-13\"]" + batchSize + "[font=\"serif-13\"] units; " +
|
||||
"Shift-click to train [font=\"serif-bold-13\"]"+ (batchSize+batchIncrement) + "[font=\"serif-13\"] units[/font]";
|
||||
}
|
||||
break;
|
||||
|
||||
tooltip += "\n" + getEntityCost(template);
|
||||
break;
|
||||
case CONSTRUCTION:
|
||||
var tooltip = getEntityNameWithGenericType(template);
|
||||
if (template.tooltip)
|
||||
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + getPopulationBonus(template) + "[/font]";
|
||||
|
||||
case COMMAND:
|
||||
if (item == "unload-all")
|
||||
{
|
||||
var count = unitEntState.garrisonHolder.entities.length;
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 0 ? count : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = "";
|
||||
}
|
||||
tooltip += "\n" + getEntityCost(template);
|
||||
break;
|
||||
|
||||
tooltip = toTitleCase(item);
|
||||
break;
|
||||
case COMMAND:
|
||||
if (item == "unload-all")
|
||||
{
|
||||
var count = unitEntState.garrisonHolder.entities.length;
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 0 ? count : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = "";
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
tooltip = toTitleCase(item);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Button
|
||||
|
|
@ -248,8 +259,8 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
|
|||
button.hidden = false;
|
||||
button.tooltip = tooltip;
|
||||
|
||||
// Button Function
|
||||
button.onpress = (function(e) { return function() { callback(e) } })(item); // (need nested functions to get the closure right)
|
||||
// Button Function (need nested functions to get the closure right)
|
||||
button.onpress = (function(e){ return function() { callback(e) } })(item);
|
||||
|
||||
// Get icon image
|
||||
if (guiName == "Formation")
|
||||
|
|
@ -290,7 +301,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
|
|||
//icon.cell_id = i;
|
||||
//icon.cell_id = getCommandCellId(item);
|
||||
icon.sprite = "stretched:session/icons/single/" + getCommandImage(item);
|
||||
|
||||
|
||||
}
|
||||
else if (template.icon)
|
||||
{
|
||||
|
|
@ -326,7 +337,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
|
|||
for (var i = 0; i < numRows; i++)
|
||||
layoutButtonRow(i, guiName, buttonSideLength, buttonSpacer, rowLength*i, rowLength*(i+1) );
|
||||
}
|
||||
|
||||
|
||||
// Resize Queue panel if needed
|
||||
if (guiName == "Queue") // or garrison
|
||||
{
|
||||
|
|
@ -347,7 +358,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
|
|||
function updateUnitCommands(entState, supplementalDetailsPanel, commandsPanel, selection)
|
||||
{
|
||||
//var isInvisible = true;
|
||||
|
||||
|
||||
// Panels that are active
|
||||
var usedPanels = {};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue