1
0
forked from 0ad/0ad

Basic progress bar UI at the start of the game requested by Jan, so player is aware of and can cancel archive building.

(Note that the Esc key is now used here, so you'll have to use another
key ... Ctrl+F4/Alt+F4/Ctrl+Break to quick-kill the game.)

Also set Matei's StartProduction to use entity's creation time.

This was SVN commit r3556.
This commit is contained in:
Acumen 2006-02-23 18:22:30 +00:00
parent e959e59614
commit da2178db66
4 changed files with 102 additions and 42 deletions

View File

@ -108,13 +108,15 @@ sound.mastergain = 0.5
; useful for people without access to said file.
; > SYSTEM SETTINGS
hotkey.exit = Escape, "Ctrl+F4" ; Exit to desktop.
hotkey.exit = "Ctrl+F4", "Alt+F4", "Ctrl+Break" ; Exit to desktop.
hotkey.pause = Pause ; Pause/unpause game.
hotkey.screenshot = F2 ; Take PNG screenshot.
hotkey.bigscreenshot = "Ctrl+Alt+F2" ; Take large BMP screenshot.
hotkey.screenshot.watermark = "W" ; Toggle product/company watermark for official
hotkey.wireframe = "Alt+W" ; Toggle wireframe mode.
hotkey.archive.abort = "Escape" ; Prematurely terminate the archive builder process.
; > CAMERA SETTINGS
hotkey.camera.reset = "H" ; Reset camera rotation to default.
hotkey.camera.reset.origin = "Ctrl+H" ; Reset camera to origin.

View File

@ -234,9 +234,6 @@ function entityInit()
this.traits.ai.stance.curr = "Avoid";
}
/*
// Generate entity's personal name (if it needs one).
if (this.traits.id.personal)
@ -428,9 +425,9 @@ function performHeal( evt )
pool = this.player.resource;
for( resource in pool )
{
switch( resource.toString().toUpperCase() )
switch( resource.toString() )
{
case "POPULATION" || "HOUSING":
case "Population" || "Housing":
break;
default:
// Make sure we have enough resources.
@ -455,9 +452,9 @@ function performHeal( evt )
pool = this.player.resource;
for( resource in pool )
{
switch( resource.toString().toUpperCase() )
switch( resource.toString() )
{
case "POPULATION" || "HOUSING":
case "Population" || "Housing":
break;
default:
// Deduct resources to pay for healing.
@ -796,7 +793,8 @@ function entityEventPrepareOrder( evt )
function entityStartProduction( evt )
{
console.write("StartProduction: " + evt.productionType + " " + evt.name);
evt.time = 5.0;
// Set the amount of time it will take to complete production of the production object.
evt.time = getTemplate(evt.name).traits.creation.time;
}
function entityFinishProduction( evt )
@ -908,15 +906,16 @@ function attemptAddToBuildQueue( entity, create_tag, tab, list )
template = getEntityTemplate( create_tag );
result = entityCheckQueueReq( entity, template );
if (result == "true") // If the entry meets requirements to be added to the queue (eg sufficient resources)
if (result == true) // If the entry meets requirements to be added to the queue (eg sufficient resources)
{
// Cycle through all costs of this entry.
pool = template.traits.creation.resource;
for ( resource in pool )
{
switch( resource.toString().toUpperCase() )
switch ( getGUIGlobal().toTitleCase(resource.toString()) )
{
case "POPULATION" || "HOUSING":
case "Population":
case "Housing":
break;
default:
// Deduct the given quantity of resources.
@ -931,9 +930,14 @@ function attemptAddToBuildQueue( entity, create_tag, tab, list )
// Add entity to queue.
console.write( "Adding ", create_tag, " to build queue..." );
entity.addCreateQueue( template, tab, list );
return true;
}
else // If not, output the error message.
else
{ // If not, output the error message.
console.write(result);
return false;
}
}
// ====================================================================
@ -948,26 +952,24 @@ function entityCheckQueueReq( entity, template )
resources = template.traits.creation.resource;
for( resource in resources )
{
resourceU = resource.toString().toUpperCase();
switch( resourceU )
switch( getGUIGlobal().toTitleCase(resource.toString()) )
{
case "POPULATION":
case "Population":
// If the item costs more of this resource type than we have,
if (template.traits.population.rem > (localPlayer.resource["HOUSING"]-localPlayer.resource[resourceU]))
if (template.traits.population.rem > (localPlayer.resource["Housing"]-localPlayer.resource[resource]))
{
// Return an error.
return ("Insufficient Housing; " + (resources[resource]-localPlayer.resource["HOUSING"]-localPlayer.resource.valueOf()[resourceU].toString()) + " required.");
return ("Insufficient Housing; " + (resources[resource]-localPlayer.resource["Housing"]-localPlayer.resource.valueOf()[resource].toString()) + " required.");
}
break;
case "HOUSING": // Ignore housing. It's handled in combination with population.
case "Housing": // Ignore housing. It's handled in combination with population.
break
default:
// If the item costs more of this resource type than we have,
if (resources[resource] > localPlayer.resource[resourceU])
if (resources[resource] > localPlayer.resource[resource])
{
// Return an error.
return ("Insufficient " + resource + "; " + (localPlayer.resource[resourceU]-resources[resource])*-1 + " required.");
return ("Insufficient " + resource + "; " + (localPlayer.resource[resource]-resources[resource])*-1 + " required.");
}
else
console.write("Player has at least " + resources[resource] + " " + resource + ".");
@ -982,7 +984,7 @@ function entityCheckQueueReq( entity, template )
// Check if the limit for this type of entity has been reached.
// If we passed all checks, return success. Entity can be queued.
return "true";
return true;
}
// ====================================================================

View File

@ -4,6 +4,58 @@
<objects>
<!--
==========================================
- PROGRESS BAR FOR ARCHIVE BUILDER
==========================================
-->
<object name="ab"
type="button"
size="0 0 100% 100%"
ghost="false"
hotkey="archive.abort"
sprite="bkFillBlack"
>
<action on="Press"><![CDATA[
// If the user aborts the archive, switch to the main menu.
startMainMenu();
]]></action>
<object name="abProgressBarText"
type="text"
size="25 100%-190 100%-25 100%-180"
font="tahoma14"
textcolor="255 255 255"
text_align="center"
text_valign="center"
>
Rebuilding Archive ... Press Esc or Left-Click to Cancel
</object>
<object name="abProgressBar"
style="wheatProgressBarBlue"
type="progressbar"
size="25 100%-160 100%-25 100%-145"
>
<action on="Load"><![CDATA[
// Reset progress bar to zero at start of game.
// (Putting it at half for the moment so we have something to see)
this.caption = 50; // 0;
// Use waiting cursor.
setCursor ("cursor-wait");
]]></action>
<action on="Archive"><![CDATA[
// Jan: Please insert your equivalent event and variable for archive progress here.
// this.caption = g_Progress;
]]></action>
<action on="ArchiveComplete"><![CDATA[
// When the archive is finished, switch to the main menu.
startMainMenu();
]]></action>
</object>
</object>
<!--
==========================================
- MAIN MENU - "COMMANDER'S TENT" BACKDROP
@ -13,19 +65,8 @@
<object name="pg"
type="image"
sprite="pgBackground"
hidden="true"
>
<action on="Load"><![CDATA[
// Play main 0 A.D. theme when the main menu starts.
curr_music = newRandomSound("music", "menu");
curr_music.loop();
// Display a .cfg file variable to prove we can access it.
// console.write ("Volume: " + g_ConfigDB.system["sound.mastergain"] + ".")
// Unfortunately, although Philip's workaround certainly works,
// a] The value cannot be modified.
// b] Variables a step up in the hierarchy are not recognised (eg system.sound.mastergain).
]]></action>
<!--
==========================================
- MAIN MENU - STATIC TOOLTIP WINDOW

View File

@ -5,6 +5,21 @@
// ====================================================================
// Switch from the archive builder to the main menu.
function startMainMenu()
{
// Reveal the main menu now that the archive has been loaded.
guiHide ("ab");
guiUnHide ("pg");
// Play main 0 A.D. theme when the main menu starts.
curr_music = newRandomSound("music", "menu");
curr_music.loop();
// Switch to standard pointer.
setCursor ("arrow-default");
}
// ====================================================================
// Helper function that enables the dark background mask, then reveals a given subwindow object.
function openMainMenuSubWindow (windowName)
{