Train lists now support a basic progress bar and unit counters. Still to come ... Removing entries from the queue by right-clicking buttons, prerequisites and resource costs.

This was SVN commit r2147.
This commit is contained in:
Acumen 2005-04-19 02:06:18 +00:00
parent 3a36e9fa43
commit 3d59ecab85
4 changed files with 62 additions and 9 deletions

View File

@ -179,13 +179,20 @@ function entity_event_prepareorder( evt )
}
}
function entity_add_create_queue( template )
function entity_add_create_queue( template, list, tab )
{
// Make sure we have a queue to put things in...
if( !this.actions.create.queue )
this.actions.create.queue = new Array();
this.actions.create.queue = new Array();
// Construct template object.
comboTemplate = template;
comboTemplate.list = list;
comboTemplate.tab = tab;
// Append to the end of this queue
this.actions.create.queue.valueOf().push( template );
this.actions.create.queue.valueOf().push( comboTemplate );
// If we're not already building something...
if( !this.actions.create.progress || !this.actions.create.progress.valueOf() )
{
@ -255,8 +262,8 @@ function entity_create_complete()
}
}
function attempt_add_to_build_queue( entity, create_tag )
function attempt_add_to_build_queue( entity, create_tag, list, tab )
{
console.write( "Adding ", create_tag, " to build queue..." );
entity.add_create_queue( getEntityTemplate( create_tag ) );
entity.add_create_queue( getEntityTemplate( create_tag ), list, tab );
}

View File

@ -415,6 +415,8 @@
]]></action>
</object>
<object type="progressbar" name="SN_STATUS_PANE_COMMAND_PROGRESS" style="portrait_progress" ><action on="Load"><![CDATA[ addSizeCoordArray(this.name, Crd[SN_STATUS_PANE_COMMAND_PROGRESS]); ]]></action></object>
<!-- / GROUP: STATUS ORB -->
</object>

View File

@ -227,8 +227,6 @@ function initStatusOrb()
{
for (SN_STATUS_PANE_COMMAND.list.curr = 1; SN_STATUS_PANE_COMMAND.list.curr <= SN_STATUS_PANE_COMMAND.list.max; SN_STATUS_PANE_COMMAND.list.curr++)
{
// MT: What's going on here?
SN_STATUS_PANE_COMMAND[SN_STATUS_PANE_COMMAND.list.curr][SN_STATUS_PANE_COMMAND.tab.curr] = new Number( addArrayElement(Crd, Crd.last) );
Crd[Crd.last-1].rleft = left_screen; Crd[Crd.last-1].rtop = bottom_screen;
Crd[Crd.last-1].rright = left_screen; Crd[Crd.last-1].rbottom = bottom_screen;
@ -316,6 +314,14 @@ function initStatusOrb()
}
}
}
SN_STATUS_PANE_COMMAND_PROGRESS = addArrayElement(Crd, Crd.last);
Crd[Crd.last-1].rleft = left_screen; Crd[Crd.last-1].rtop = bottom_screen;
Crd[Crd.last-1].rright = left_screen; Crd[Crd.last-1].rbottom = bottom_screen;
Crd[Crd.last-1].width = crd_portrait_sml_width;
Crd[Crd.last-1].height = crd_portrait_sml_height;
Crd[Crd.last-1].x = Crd[SN_STATUS_PANE_BG].x+Crd[SN_STATUS_PANE_BG].width;
Crd[Crd.last-1].y = Crd[SN_STATUS_PANE_BG].y;
}
// ====================================================================
@ -376,6 +382,7 @@ function UpdateList(listIcon, listCol)
UpdateListEntityName = selection[0].traits.id.civ_code + "_" + listArray[createLoop];
setPortrait("SN_STATUS_PANE_COMMAND_" + listCol + "_" + parseInt(createLoop+2), getEntityTemplate(UpdateListEntityName).traits.id.icon, selection[0].traits.id.civ_code, getEntityTemplate(UpdateListEntityName).traits.id.icon_cell);
getGUIObjectByName("SN_STATUS_PANE_COMMAND_" + listCol + "_" + parseInt(createLoop+2)).caption = "";
GUIObjectUnhide("SN_STATUS_PANE_COMMAND_" + listCol + "_" + parseInt(createLoop+2));
// Store content info in tab button for future reference.
@ -445,10 +452,9 @@ function PressCommandButton(GUIObject, list, tab)
// }
break;
default:
GUIObject.caption = list-1;
console.write("Clicked [" + list + "," + tab + "]: list of type " + SN_STATUS_PANE_COMMAND[list][tab].type + "; " + SN_STATUS_PANE_COMMAND[list][tab].name);
attempt_add_to_build_queue( selection[0], selection[0].traits.id.civ_code + "_" + SN_STATUS_PANE_COMMAND[list][tab].name );
attempt_add_to_build_queue( selection[0], selection[0].traits.id.civ_code + "_" + SN_STATUS_PANE_COMMAND[list][tab].name, list, tab);
break;
}
}
@ -483,6 +489,34 @@ function UpdateCommandButtons()
// If this slot could possibly contain a list, hide that too.
GUIObjectHide("SN_STATUS_PANE_COMMAND_" + commandClearLoop + "_GROUP");
}
// Update production queue.
GUIObject = getGUIObjectByName("SN_STATUS_PANE_COMMAND_PROGRESS");
// If the entity has a production item underway,
if (selection[0].actions.create && selection[0].actions.create.progress && selection[0].actions.create.progress.valueOf() && selection[0].actions.create.progress.valueOf().current && selection[0].actions.create.queue.valueOf() && selection[0].actions.create.queue.valueOf()[0].traits.creation.time)
{
// Set the value of the production progress bar.
GUIObject.caption = ((Math.round(Math.round(selection[0].actions.create.progress.valueOf().current)) * 100 ) / Math.round(selection[0].actions.create.queue.valueOf()[0].traits.creation.time));
// Set position of progress bar.
GUIObject.size = getGUIObjectByName("SN_STATUS_PANE_COMMAND_" + selection[0].actions.create.queue.valueOf()[0].tab + "_" + selection[0].actions.create.queue.valueOf()[0].list).size;
// Set progress bar tooltip.
GUIObject.tooltip = "Training " + selection[0].actions.create.queue.valueOf()[0].traits.id.generic + " ... " + (Math.round(selection[0].actions.create.queue.valueOf()[0].traits.creation.time-Math.round(selection[0].actions.create.progress.valueOf().current)) + " seconds remaining.");
// Reveal progressbar.
GUIObject.hidden = false;
// Seek through queue.
for( queueEntry = 0; queueEntry < selection[0].actions.create.queue.valueOf().length; queueEntry++)
{
// Update list buttons so that they match the number of entries of that type in the queue.
getGUIObjectByName("SN_STATUS_PANE_COMMAND_" + selection[0].actions.create.queue.valueOf()[queueEntry].tab + "_" + selection[0].actions.create.queue.valueOf()[queueEntry].list).caption++;
}
}
else
{
// Hide the progress bar.
GUIObject.hidden = true;
GUIObject.tooltip = "";
}
}
// ====================================================================

View File

@ -178,6 +178,16 @@
tooltip="(TBA)"
/>
<style name="portrait_progress"
sprite_background=""
sprite_bar="translucent_background"
text_align="center"
text_valign="center"
textcolor="255 255 255"
tooltip_style="session_tooltip"
tooltip="(TBA)"
/>
<style name="action"
sprite="ui_portrait_default_circle"
sprite_over="ui_portrait_default_circle_lit"