From da2178db66f801bd09058123b322e4651d868bc4 Mon Sep 17 00:00:00 2001 From: Acumen Date: Thu, 23 Feb 2006 18:22:30 +0000 Subject: [PATCH] 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. --- binaries/data/config/system.cfg | 12 ++-- .../entities/template_entity_script.js | 52 ++++++++------- .../mods/official/gui/test/2_mainmenu.xml | 65 +++++++++++++++---- .../gui/test/functions_page_pregame.js | 15 +++++ 4 files changed, 102 insertions(+), 42 deletions(-) diff --git a/binaries/data/config/system.cfg b/binaries/data/config/system.cfg index 2c6b229a32..0ae2739982 100644 --- a/binaries/data/config/system.cfg +++ b/binaries/data/config/system.cfg @@ -108,12 +108,14 @@ sound.mastergain = 0.5 ; useful for people without access to said file. ; > SYSTEM SETTINGS -hotkey.exit = Escape, "Ctrl+F4" ; Exit to desktop. -hotkey.pause = Pause ; Pause/unpause game. -hotkey.screenshot = F2 ; Take PNG screenshot. +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.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. diff --git a/binaries/data/mods/official/entities/template_entity_script.js b/binaries/data/mods/official/entities/template_entity_script.js index 63944c4147..f3427aeb76 100644 --- a/binaries/data/mods/official/entities/template_entity_script.js +++ b/binaries/data/mods/official/entities/template_entity_script.js @@ -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,21 +906,22 @@ 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 ) + 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. - getGUIGlobal().deductResources(resource.toString(), parseInt(pool[resource])); + getGUIGlobal().deductResources (resource.toString(), parseInt(pool[resource])); - console.write("Spent " + pool[resource] + " " + resource + " to purchase " + + console.write ("Spent " + pool[resource] + " " + resource + " to purchase " + template.traits.id.generic); break; } @@ -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; } // ==================================================================== diff --git a/binaries/data/mods/official/gui/test/2_mainmenu.xml b/binaries/data/mods/official/gui/test/2_mainmenu.xml index 12095546d3..0ab5254326 100644 --- a/binaries/data/mods/official/gui/test/2_mainmenu.xml +++ b/binaries/data/mods/official/gui/test/2_mainmenu.xml @@ -4,6 +4,58 @@ + + + + + + + Rebuilding Archive ... Press Esc or Left-Click to Cancel + + + + + + + + +