MCPcopy Create free account
hub / github.com/Shazbot/WH3-Mod-Manager / createWindow

Function createWindow

src/index.ts:90–466  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88 };
89
90 const createWindow = (): void => {
91 i18n.on("loaded", async () => {
92 // Get the OS locale and check if it's supported
93 const osLocale = app.getLocale();
94 const primaryLanguage = osLocale.split("-")[0]; // Extract primary language (e.g., 'en' from 'en-US')
95
96 // Check if the primary language is in our supported languages list
97 const osLanguageToUse = isSupportedLanguage(primaryLanguage) ? primaryLanguage : "en";
98
99 const languageToUse = appData.currentLanguage ? appData.currentLanguage : osLanguageToUse;
100 appData.currentLanguage = languageToUse;
101
102 console.log(`OS Locale: ${osLocale}, Primary Language: ${primaryLanguage}, Using: ${languageToUse}`);
103
104 i18n.changeLanguage(languageToUse);
105 i18n.off("loaded");
106
107 console.log("I18N initialized with language:", languageToUse);
108 });
109
110 const mainWindowState = windowStateKeeper({
111 file: "main_window.json",
112 defaultWidth: 1280,
113 defaultHeight: 900,
114 });
115
116 // Create the browser window.
117 windows.mainWindow = new BrowserWindow({
118 x: mainWindowState.x,
119 y: mainWindowState.y,
120 width: mainWindowState.width,
121 height: mainWindowState.height,
122 autoHideMenuBar: true,
123 titleBarStyle: "hidden",
124 titleBarOverlay: {
125 color: "#374151",
126 symbolColor: "#9ca3af",
127 height: 28,
128 },
129 webPreferences: {
130 nodeIntegration: true,
131 contextIsolation: false,
132 preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
133 spellcheck: false,
134 },
135 title: "WH3 Mod Manager",
136 icon: "./assets/modmanager.ico",
137 });
138
139 mainWindowState.manage(windows.mainWindow);
140
141 // and load the index.html of the app.
142 windows.mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
143
144 windows.mainWindow.webContents.setWindowOpenHandler(({ url }) => {
145 shell.openExternal(url);
146 return { action: "deny" };
147 });

Callers 1

index.tsFile · 0.85

Calls 5

isSupportedLanguageFunction · 0.90
registerIpcMainListenersFunction · 0.90
downloadFileFunction · 0.85
closeMethod · 0.80

Tested by

no test coverage detected