source: subversion/applications/utils/garmin-mapsource-installer/garmin-mapsource-installer.au3 @ 29923

Last change on this file since 29923 was 17686, checked in by avar, 10 years ago

Not using the version variable anymore

File size: 4.5 KB
Line 
1#NoTrayIcon
2#include <GUIConstants.au3>
3
4Global $s_DatFile = @ScriptDir & '\' & 'garmin-mapsource-installer.ini'
5Global $s_MapSourceDir = RegRead('HKLM\Software\Garmin\MapSource\Products', 'InstallDir')
6Global $s_OpenStreetMapDir = $s_MapSourceDir & "OpenStreetMap"
7
8_LoadUpdateData()
9
10Opt("GuiResizeMode", $GUI_DOCKALL)
11$gui_Main = GuiCreate($t_application_name, 350, 90)
12
13;; A <hr>
14GuiCtrlCreateLabel('', 0, 0, 350, 2, $SS_SUNKEN)
15
16$gr_Instal_Details=GuiCtrlCreateGroup($t_installation_path, 5, 5, 340, 50)
17$hFile = GUICtrlCreateEdit($s_OpenStreetMapDir, 10,  25, 250, 20, $ES_READONLY, $WS_EX_STATICEDGE)
18GUICtrlSetCursor(-1, 2)
19GUICtrlSetState(-1, $GUI_ACCEPTFILES)
20$bt_Path_Selector = GUICtrlCreateButton($t_path_edit, 265,  25, 75, 20)
21
22GUIStartGroup()
23
24$bt_Install = GuiCtrlCreateButton($t_install, 5, 60, 340, 25)
25
26;
27; Start application
28;
29
30; Show main window
31GuiSetState(@SW_SHOW, $gui_Main)
32
33While 1
34        $a_GMsg = GUIGetMsg(1)
35
36        If $a_GMsg[1] = $gui_Main Then
37                Select
38            Case $a_GMsg[0] = $bt_Path_Selector
39                $sTmpFile = FileSelectFolder("Select a custom install location:", "", 1 + 2 + 4, $s_MapSourceDir)
40                If @error Then ContinueLoop
41                GUICtrlSetData($hFile, $sTmpFile)
42
43
44                        ; Install
45                        Case $a_GMsg[0] = $bt_Install
46                                _Install()
47
48            Case $a_GMsg[0] = $GUI_EVENT_CLOSE
49                Exit
50        EndSelect
51    EndIf
52Wend
53
54Func _LoadUpdateData()
55    ;; ==================
56    ;; Get global section
57    ;; ==================
58
59        Global $t_global_language = IniRead($s_DatFile, 'Global', 'language', '%language%')
60
61    ;; =======================
62    ;; Get i18n from .ini file
63    ;; =======================
64
65    ;; Find out what language we're using to get those translation strings
66    Local $lang_ini_section = 'Language_' & $t_global_language
67
68    ;; Get i18n strings
69    Global $t_application_name = IniRead($s_DatFile, $lang_ini_section, 'application_name', '%application_name%')
70    Global $t_application_description = IniRead($s_DatFile, $lang_ini_section, 'application_description', '%application_description%')
71    Global $t_help_menu = IniRead($s_DatFile, $lang_ini_section, 'help_menu', '%help_menu%')
72    Global $t_help_menu_website = IniRead($s_DatFile, $lang_ini_section, 'help_menu_website', '%help_menu_website%')
73    Global $t_help_menu_website_url = IniRead($s_DatFile, $lang_ini_section, 'help_menu_website_url', '%help_menu_website_url%')
74    Global $t_help_menu_about = IniRead($s_DatFile, $lang_ini_section, 'help_menu_about', '%help_menu_about%')
75    Global $t_help_menu_about_title = IniRead($s_DatFile, $lang_ini_section, 'help_menu_about_title', '%help_menu_about_title%')
76    Global $t_help_menu_about_text = IniRead($s_DatFile, $lang_ini_section, 'help_menu_about_text', '%help_menu_about_text%')
77    Global $t_help_menu_about_contact = IniRead($s_DatFile, $lang_ini_section, 'help_menu_about_contact', '%help_menu_about_contact%')
78    Global $t_help_menu_about_website = IniRead($s_DatFile, $lang_ini_section, 'help_menu_about_website', '%help_menu_about_website%')
79
80    Global $t_install = IniRead($s_DatFile, $lang_ini_section, 'install', '%install%')
81    Global $t_installation_path = IniRead($s_DatFile, $lang_ini_section, 'installation_path', '%installation_path%')
82    Global $t_path_edit = IniRead($s_DatFile, $lang_ini_section, 'path_edit', '%path_edit%')
83EndFunc
84
85Func _Install()
86
87    Local $family = IniRead($s_DatFile, 'Map', 'Family', '')
88    Local $id = IniRead($s_DatFile, 'Map', 'ID', '')
89    Local $bmap = IniRead($s_DatFile, 'Map', 'BMAP', '')
90    Local $tdb = IniRead($s_DatFile, 'Map', 'TDB', '')
91    Local $other = IniRead($s_DatFile, 'Map', 'other', '')
92
93        If Not RegWrite('HKLM\Software\Garmin\MapSource\Families\' & $family, "ID", "REG_BINARY", $id) Then
94        MsgBox(1, "Arghl", "Failed to set family key")
95    EndIf
96    RegWrite('HKLM\Software\Garmin\MapSource\Families\' & $family & '\1', "BMAP", "REG_SZ", $s_OpenStreetMapDir & '\' & $bmap)
97    RegWrite('HKLM\Software\Garmin\MapSource\Families\' & $family & '\1', "TDB", "REG_SZ", $s_OpenStreetMapDir & '\' & $tdb)
98    RegWrite('HKLM\Software\Garmin\MapSource\Families\' & $family & '\1', "LOC", "REG_SZ", $s_OpenStreetMapDir & '\')
99
100    If Not DirCreate($s_OpenStreetMapDir) Then
101        MsgBox(1, "Arghl", "Failed to create install dir")
102    EndIf
103
104    FileCopy(@ScriptDir & '\' & $bmap, $s_OpenStreetMapDir, 1)
105    FileCopy(@ScriptDir & '\' & $tdb, $s_OpenStreetMapDir, 1)
106    FileCopy(@ScriptDir & '\' & $other, $s_OpenStreetMapDir, 1)
107
108    MsgBox(1, 'Yay', 'Your map was successfully installed, you can now exit the application')
109EndFunc
Note: See TracBrowser for help on using the repository browser.