Skip to content

Commit

Permalink
WC: Player count is now an option in the settings dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Jul 11, 2021
1 parent a07328a commit 961f2f6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
24 changes: 23 additions & 1 deletion data/campaigns/World_Conquest/gui/settings_dialog.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@
vertical_grow = true
[grid]
[row]
[column]
[label]
label = _" players: "
width=20
[/label]
[/column]
[column]
[slider]
definition="short"
id = "sl_players"
minimum_value=1
maximum_value=3
[/slider]
[/column]
[column]
[label]
label = _" scenario: "
Expand All @@ -55,9 +69,17 @@
definition="short"
id = "sl_scenario"
minimum_value=1
maximum_value=6
maximum_value=5
[/slider]
[/column]
[column]
[spacer]
[/spacer]
[/column]
[column]
[spacer]
[/spacer]
[/column]
[column]
[label]
label = _" map: "
Expand Down
18 changes: 14 additions & 4 deletions data/campaigns/World_Conquest/lua/map/settings/settings_dialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ end

local dialog_wml = wml.load "campaigns/World_Conquest/gui/settings_dialog.cfg"

function wc2_debug_settings(nplayers)
function wc2_debug_settings()


local function preshow(window)

local sl_scenario = window.sl_scenario
local sl_map = window.sl_map
local sl_players = window.sl_players

local function on_set_map()

globals.settings.scenario_num = sl_scenario.value

std_print(nplayers, globals.settings.scenario_num)
local generators = get_defaults(nplayers, globals.settings.scenario_num)
std_print(sl_players.value, globals.settings.scenario_num)
local generators = get_defaults(sl_players.value, globals.settings.scenario_num)
local map_data = generators[sl_map.value]
if map_data then

Expand All @@ -63,22 +64,31 @@ function wc2_debug_settings(nplayers)

local function on_set_scenario()
globals.settings.scenario_num = sl_scenario.value
get_defaults(nplayers, globals.settings.scenario_num)
get_defaults(sl_players.value, globals.settings.scenario_num)
on_set_map()
end

local function on_set_players()
globals.settings.nplayers = sl_players.value
get_defaults(sl_players.value, globals.settings.scenario_num)
on_set_map()
end


sl_scenario.value = globals.settings.scenario_num or 1
sl_map.value = globals.settings.map_num or 1
sl_players.value = globals.settings.nplayers or 1
sl_scenario.on_modified = on_set_scenario
sl_map.on_modified = on_set_map
sl_players.on_modified = on_set_players

on_set_map()
end

local function postshow(window)
globals.settings.scenario_num = window.sl_scenario.value
globals.settings.map_num = window.sl_map.value
globals.settings.nplayers = window.sl_players.value

globals.settings.length = window.sl_length.value
globals.settings.villages = window.sl_villages.value
Expand Down
8 changes: 7 additions & 1 deletion data/campaigns/World_Conquest/scenarios/WC_II_scenario.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ _ "World Conquest 3p" #enddef
local function doit()
wesnoth.dofile('campaigns/World_Conquest//lua/map/main.lua');
wesnoth.dofile('campaigns/World_Conquest//lua/map/settings/settings_dialog.lua');
return wc2_debug_settings(a.nplayers)
return wc2_debug_settings()
end

local status, res = xpcall(doit, function(e) std_print(e, debug.traceback()) end)
Expand All @@ -150,6 +150,10 @@ _ "World Conquest 3p" #enddef
{WC2_CAMPAIGN_NEW 2}
{WC2_CAMPAIGN_NEW 3}

#ifdef EDITOR
{WC2_SCENARIO_NEW multiplayer WC_II {WC_II_CAMPAIGN_NAME_3P} 0}
#else

#ifdef CAMPAIGN_WC_1P
{WC2_SCENARIO_NEW scenario "WC_II_1p" {WC_II_CAMPAIGN_NAME_1P} 1}
#endif
Expand All @@ -161,3 +165,5 @@ _ "World Conquest 3p" #enddef
#ifdef CAMPAIGN_WC_3P
{WC2_SCENARIO_NEW scenario "WC_II_3p" {WC_II_CAMPAIGN_NAME_3P} 3}
#endif

#endif

0 comments on commit 961f2f6

Please sign in to comment.