1111import com .botwithus .bot .cli .stream .StreamManager ;
1212import com .botwithus .bot .core .config .ScriptProfileStore ;
1313
14+ import imgui .ImFontAtlas ;
1415import imgui .ImFontConfig ;
1516import imgui .ImGui ;
16- import imgui .ImGuiIO ;
1717import imgui .app .Application ;
1818import imgui .app .Configuration ;
1919import imgui .flag .ImGuiConfigFlags ;
@@ -68,8 +68,8 @@ public class ImGuiApp extends Application {
6868 private boolean editorMode = false ;
6969 private BlueprintEditor blueprintEditor ;
7070
71- // Script config panel (floating window)
72- private ScriptConfigPanel configPanel ;
71+ // Script custom UI window (floating window)
72+ private ScriptUIWindow scriptUIWindow ;
7373
7474 // GLFW window handle for title updates
7575 private long glfwWindow ;
@@ -94,18 +94,24 @@ protected void initImGui(Configuration config) {
9494 }
9595 float dpiScale = Math .max (xScale [0 ], 1.0f );
9696
97- // Rebuild font atlas at scaled pixel size so text is crisp on HiDPI.
98- ImGuiIO io = ImGui .getIO ();
99- io .getFonts ().clear ();
100- ImFontConfig fontConfig = new ImFontConfig ();
101- fontConfig .setSizePixels (14f * dpiScale );
102- fontConfig .setOversampleH (2 );
103- fontConfig .setOversampleV (2 );
104- io .getFonts ().addFontDefault (fontConfig );
105- io .getFonts ().build ();
106- fontConfig .destroy ();
97+ float uiSize = (float ) Math .round (19f * dpiScale );
98+ ImFontAtlas atlas = ImGui .getIO ().getFonts ();
99+ atlas .clear ();
100+ byte [] ttf = loadSystemFont ("segoeui.ttf" , "arial.ttf" , "verdana.ttf" );
101+ ImFontConfig cfg = new ImFontConfig ();
102+ cfg .setOversampleH (3 );
103+ cfg .setOversampleV (3 );
104+ cfg .setPixelSnapH (true );
105+ if (ttf != null ) {
106+ atlas .addFontFromMemoryTTF (ttf , uiSize , cfg );
107+ } else {
108+ cfg .setSizePixels (uiSize );
109+ atlas .addFontDefault (cfg );
110+ }
111+ cfg .destroy ();
112+ atlas .build ();
107113
108- io .addConfigFlags (ImGuiConfigFlags .ViewportsEnable );
114+ ImGui . getIO () .addConfigFlags (ImGuiConfigFlags .ViewportsEnable );
109115
110116 ImGuiTheme .apply (dpiScale );
111117
@@ -193,9 +199,9 @@ public void completeWithError(Object handle, String message) {
193199 // Initialize blueprint editor
194200 blueprintEditor = new BlueprintEditor ();
195201
196- // Initialize config panel and wire opener
197- configPanel = new ScriptConfigPanel ();
198- ctx .setConfigPanelOpener (runner -> configPanel .open (runner ));
202+ // Initialize script UI window and wire opener
203+ scriptUIWindow = new ScriptUIWindow ();
204+ ctx .setConfigPanelOpener (runner -> scriptUIWindow .open (runner ));
199205
200206 // Initialize panels
201207 panels .add (new ConsolePanel (outputBuffer , registry , executor , this ::shutdown ));
@@ -208,8 +214,10 @@ public void completeWithError(Object handle, String message) {
208214
209215 statusBar = new StatusBar ();
210216
211- // Grab GLFW window handle for title updates
212217 glfwWindow = GLFW .glfwGetCurrentContext ();
218+
219+ var oldSizeCb = GLFW .glfwSetWindowSizeCallback (glfwWindow , null );
220+ if (oldSizeCb != null ) oldSizeCb .free ();
213221 }
214222
215223 @ Override
@@ -273,15 +281,28 @@ public void process() {
273281
274282 ImGui .end ();
275283
276- // Render config panel as floating window (outside the main window)
277- if (configPanel != null && configPanel .isOpen ()) {
278- configPanel .render ();
284+ // Render script custom UI as a floating window (outside the main window)
285+ if (scriptUIWindow != null && scriptUIWindow .isOpen ()) {
286+ scriptUIWindow .render ();
279287 }
280288
281289 // Update window title based on connection state
282290 updateTitle ();
283291 }
284292
293+ private static byte [] loadSystemFont (String ... candidates ) {
294+ String windir = System .getenv ("WINDIR" );
295+ if (windir == null ) windir = "C:\\ Windows" ;
296+ java .nio .file .Path fontsDir = java .nio .file .Paths .get (windir , "Fonts" );
297+ for (String name : candidates ) {
298+ java .nio .file .Path p = fontsDir .resolve (name );
299+ if (java .nio .file .Files .exists (p )) {
300+ try { return java .nio .file .Files .readAllBytes (p ); } catch (Exception ignored ) {}
301+ }
302+ }
303+ return null ;
304+ }
305+
285306 private void updateTitle () {
286307 if (glfwWindow == 0 ) return ;
287308 boolean connected = ctx .hasActiveConnection ();
0 commit comments