Skip to content

Commit 8e048a6

Browse files
Set default mode
1 parent 379133f commit 8e048a6

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

kratos.gid/exec/launch.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
{
22
"configurations": [
33
{
4-
"id": "pip",
54
"name": "Launch via pip",
65
"runtimeExecutable": "python.exe"
76
},
87
{
9-
"id": "localpip",
108
"name": "Launch via pip with local packages",
119
"runtimeExecutable": "python.exe"
1210
},
1311
{
14-
"id": "local",
1512
"name": "Launch local compiled version",
1613
"kratos_path": "E:/Deploy_Kratos",
1714
"runtimeExecutable": "python.exe"
1815
},
1916
{
20-
"id": "docker",
17+
"name": "Docker",
2118
"image": ""
2219
}
2320
]

kratos.gid/kratos.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ proc Kratos::Event_InitProblemtype { dir } {
113113
# Load the Kratos problemtype global and user environment (stored preferences)
114114
Kratos::LoadEnvironment
115115

116+
Kratos::SetDefaultLaunchMode
117+
116118
# Customize GiD menus to add the Kratos entry
117119
Kratos::UpdateMenus
118120

kratos.gid/scripts/Controllers/Preferences.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919
<option value='2' label='2'/>
2020
</combobox>
2121
<entrywithbutton name="debug_folder" label="Debug path" variable="debug_folder" buttonimage="folder.png" variablemanager='Kratos::ManagePreferences' buttonfunction="OpenBrowserForDirectory" help='Path to the kratos debug folder. This is placed in the launch.json file for debugging' />
22-
<entry name="launch_configuration" label="Launch configuration" variable="launch_configuration" variablemanager='Kratos::ManagePreferences' help='' />
22+
<combobox name="launch_configuration" label="Launch configuration" variable="launch_configuration" variablemanager='Kratos::ManagePreferences' help='' >
23+
<option value='Launch via pip' label='Launch via pip'/>
24+
<option value='Launch via pip with local packages' label='Launch via pip with local packages'/>
25+
<option value='Launch local compiled version' label='Launch local compiled version'/>
26+
<option value='Docker' label='Docker'/>
27+
<option value='Custom...' label='Custom...'/>
28+
</combobox>
2329
</labelframe>
2430
</group>
2531

kratos.gid/scripts/Utils.tcl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ proc Kratos::RegisterEnvironment { } {
152152
#do not save preferences starting with flag gid.exe -c (that specify read only an alternative file)
153153
if { [GiD_Set SaveGidDefaults] } {
154154
variable kratos_private
155-
set vars_to_save [list DevMode echo_level mdpa_format debug_folder]
155+
set vars_to_save [list DevMode echo_level mdpa_format debug_folder allow_logs launch_configuration]
156156
set preferences [dict create]
157157
foreach v $vars_to_save {
158158
if {[info exists kratos_private($v)]} {
@@ -367,4 +367,16 @@ proc Kratos::LoadConfigurationFile {config_file} {
367367

368368
set dic [Kratos::ReadJsonDict $config_file]
369369
set ::Kratos::kratos_private(configurations) [dict get $dic configurations]
370+
}
371+
372+
proc Kratos::SetDefaultLaunchMode { } {
373+
set curr_mode $Kratos::kratos_private(launch_configuration)
374+
set modes [list ]
375+
set first ""
376+
foreach mode $::Kratos::kratos_private(configurations) {
377+
set mode_name [dict get $mode name]
378+
lappend modes $mode_name
379+
if {$first eq ""} {set first $mode_name}
380+
}
381+
if {$curr_mode ni $modes} {set Kratos::kratos_private(launch_configuration) $first}
370382
}

0 commit comments

Comments
 (0)