diff --git a/vasl_templates/webapp/data/default-scenario.json b/vasl_templates/webapp/data/default-scenario.json index 0926c2d..f43d380 100644 --- a/vasl_templates/webapp/data/default-scenario.json +++ b/vasl_templates/webapp/data/default-scenario.json @@ -1,5 +1,7 @@ { +"SCENARIO_THEATER": "ETO", + "PLAYER_1": "german", "PLAYER_1_ELR": "5", "PLAYER_1_SAN": "2", diff --git a/vasl_templates/webapp/static/css/tabs-scenario.css b/vasl_templates/webapp/static/css/tabs-scenario.css index 2a345ec..7694664 100644 --- a/vasl_templates/webapp/static/css/tabs-scenario.css +++ b/vasl_templates/webapp/static/css/tabs-scenario.css @@ -4,7 +4,8 @@ #panel-scenario .row { display: flex ; align-items: center ; } #panel-scenario input { flex-grow: 1 ; } -#panel-scenario input[name='SCENARIO_ID'] { margin-left: 0.25em ; width: 4em ; flex-grow: 0 ; } +#panel-scenario input[name='SCENARIO_ID'] { margin-left: 0.25em ; width: 70px ; flex-grow: 0 ; } +#panel-scenario .ui-selectmenu-button.scenario_theater { margin: -3px 0 0 0.25em ; width: 60px ; flex-grow: 0 ; } #panel-scenario input[name='SCENARIO_DATE'] { width: 6em ; flex-grow: 0 ; } #panel-scenario label { font-weight: bold ; width: 5em ; } diff --git a/vasl_templates/webapp/static/main.js b/vasl_templates/webapp/static/main.js index 8790e5e..569e728 100644 --- a/vasl_templates/webapp/static/main.js +++ b/vasl_templates/webapp/static/main.js @@ -30,7 +30,7 @@ $(document).ready( function () { // initialize the menu var $menu = $("#menu input") ; $menu.popmenu( { - new_scenario: { label: "New scenario", action: function() { on_new_scenario(true) ; } }, + new_scenario: { label: "New scenario", action: function() { on_new_scenario() ; } }, load_scenario: { label: "Load scenario", action: on_load_scenario }, save_scenario: { label: "Save scenario", action: on_save_scenario }, separator: { type: "separator" }, @@ -91,6 +91,11 @@ $(document).ready( function () { var navHeight = $("#tabs .ui-tabs-nav").height() ; $("#tabs .ui-tabs-nav a").click( function() { $(this).blur() ; } ) ; + // initialize the scenario theater + $( "select[name='SCENARIO_THEATER']" ).selectmenu( { + classes: { "ui-selectmenu-button": "scenario_theater" }, + } ) ; + // initialize the scenario date picker $("input[name='SCENARIO_DATE']").datepicker( { showAnim: "slideDown", @@ -220,7 +225,7 @@ $(document).ready( function () { } } install_template_pack( data ) ; - on_new_scenario( false ) ; + do_on_new_scenario() ; gDefaultNationalities = $.extend( true, {}, data.nationalities ) ; // NOTE: If we are loading a user-defined template pack, then what we think // is the set of valid template ID's will depend on what's in it :-/ diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js index 25f0ab4..60c16e8 100644 --- a/vasl_templates/webapp/static/snippets.js +++ b/vasl_templates/webapp/static/snippets.js @@ -228,10 +228,20 @@ function unload_snippet_params( params, check_date_capabilities ) // but by the time the filter gets called, it's too late :-( Instead, we provide a "raw_capabilities" // parameter that people can use in their templates - ugly, but probably not something that will // get a lot of use :-/ - var capabilities = make_capabilities( entry, params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities, false ) ; + var capabilities = make_capabilities( + entry, + params.SCENARIO_THEATER, + params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities, + false + ) ; if ( capabilities ) obj.capabilities = capabilities ; - capabilities = make_capabilities( entry, params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities, true ) ; + capabilities = make_capabilities( + entry, + params.SCENARIO_THEATER, + params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities, + true + ) ; if ( capabilities ) obj.raw_capabilities = capabilities ; var crew_survival = make_crew_survival( entry ) ; @@ -252,7 +262,7 @@ function unload_snippet_params( params, check_date_capabilities ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function make_capabilities( entry, scenario_year, scenario_month, check_date_capabilities, raw ) +function make_capabilities( entry, scenario_theater, scenario_year, scenario_month, check_date_capabilities, raw ) { var capabilities = [] ; @@ -523,6 +533,10 @@ function on_load_scenario_file_selected() function do_load_scenario( data, fname ) { + // NOTE: We reset the scenario first, in case the loaded scenario is missing fields, + // so that those fields will be reset to their default values (instead of just staying unchanged). + do_on_new_scenario() ; + // load the scenario try { data = JSON.parse( data ) ; @@ -742,43 +756,45 @@ function unload_params_for_save() // -------------------------------------------------------------------- -function on_new_scenario( verbose ) +function on_new_scenario() { // check if the scenario is dirty if ( ! is_scenario_dirty() ) - do_on_new_scenario() ; + do_on_new_scenario( true ) ; else { // yup - confirm the operation ask( "New scenario", "
This scenario has been changed.
Do you want to reset it, and lose your changes?", { - ok: do_on_new_scenario, + ok: function() { do_on_new_scenario( true ) ; }, cancel: function() {}, } ) ; } +} - function do_on_new_scenario() { - // load the default scenario - if ( gDefaultScenario ) - do_load_scenario_data( gDefaultScenario ) ; - else { - $.getJSON( gGetDefaultScenarioUrl, function(data) { - gDefaultScenario = data ; - do_load_scenario_data( data ) ; - update_page_load_status( "default-scenario" ) ; - } ).fail( function( xhr, status, errorMsg ) { - showErrorMsg( "Can't get the default scenario: