1
1
use super :: * ;
2
2
use crate :: { OptionDetail , Options } ;
3
- use eframe:: egui:: Label ;
4
3
use std:: collections:: HashMap ;
5
4
use std:: process:: Command ;
6
5
use std:: sync:: mpsc:: { channel, Receiver } ;
@@ -18,6 +17,7 @@ pub enum SetupScreen {
18
17
19
18
#[ derive( Debug , Default ) ]
20
19
pub struct SetupState {
20
+ pub path : String ,
21
21
pub changes : Changes ,
22
22
pub cmd : String ,
23
23
pub screen : SetupScreen ,
@@ -27,55 +27,53 @@ impl SetupState {
27
27
fn compute_command ( & mut self ) {
28
28
let mut cmd = String :: from ( "scons" ) ;
29
29
for ( k, v) in & self . changes {
30
- cmd += & format ! ( " {k}={v}" ) ;
30
+ cmd += & format ! ( " {k}={}" , v . replace ( ' ' , "_" ) ) ;
31
31
}
32
32
self . cmd = cmd;
33
33
}
34
34
}
35
35
36
36
pub fn show ( state : & mut SetupState , ctx : & Context ) -> Option < AppState > {
37
- //state.compute_command();
38
37
TopBottomPanel :: bottom ( "cmd" )
39
38
. max_height ( 150. )
40
39
. resizable ( true )
41
40
. show ( ctx, |ui| {
42
41
ScrollArea :: vertical ( ) . show ( ui, |ui| {
43
42
ui. add_space ( 6. ) ;
44
43
45
- Frame :: default ( )
46
- . inner_margin ( 6. )
47
- . rounding ( 6. )
48
- . fill ( Color32 :: from_rgb ( 22 , 22 , 22 ) )
49
- . stroke ( Stroke :: new ( 2. , Color32 :: from_rgb ( 15 , 15 , 15 ) ) )
50
- . show ( ui, |ui| {
51
- //ui.allocate_space(Vec2::new(ui.available_width(), 0.));
52
-
53
- let text = egui:: RichText :: new ( & state. cmd ) . monospace ( ) ;
54
- let label = Label :: new ( text) ;
55
- ui. add_sized ( Vec2 :: new ( ui. available_width ( ) - ui. spacing ( ) . item_spacing . x - 40. , f32:: INFINITY ) , label) ;
56
-
57
- if ui. add_sized ( Vec2 :: new ( ui. available_width ( ) , f32:: INFINITY ) , Button :: new ( "📋" ) ) . clicked ( ) {
58
- ui. ctx ( ) . copy_text ( state. cmd . clone ( ) ) ;
59
- }
44
+ ui. with_layout ( Layout :: right_to_left ( Align :: Center ) , |ui| {
45
+ if ui. button ( "📋 Copy" ) . clicked ( ) {
46
+ ui. ctx ( ) . copy_text ( state. cmd . clone ( ) ) ;
47
+ }
48
+ Frame :: default ( )
49
+ . inner_margin ( 6. )
50
+ . rounding ( 6. )
51
+ . fill ( Color32 :: from_rgb ( 22 , 22 , 22 ) )
52
+ . stroke ( Stroke :: new ( 2. , Color32 :: from_rgb ( 15 , 15 , 15 ) ) )
53
+ . show ( ui, |ui| {
54
+ let text = egui:: RichText :: new ( & state. cmd ) . monospace ( ) ;
55
+ ui. add_sized ( ui. available_size ( ) , Label :: new ( text) ) ;
56
+ } ) ;
57
+ } ) ;
60
58
61
- } ) ;
62
59
} ) ;
63
- ui. allocate_space ( Vec2 :: new ( 0. , ui. available_height ( ) ) ) ;
64
60
} ) ;
65
61
CentralPanel :: default ( ) . show ( ctx, |ui| {
66
62
ScrollArea :: vertical ( )
67
63
. auto_shrink ( false )
68
64
. show ( ui, |ui| {
65
+ ui. label ( & state. path ) ;
69
66
match & state. screen {
70
67
SetupScreen :: Start => {
71
68
let btn = Button :: new ( "Load compilation options" ) ;
72
69
if ui. add_sized ( Vec2 :: new ( 200. , 30. ) , btn) . clicked ( ) {
73
70
let ( tx, rx) = channel ( ) ;
74
-
71
+
72
+ let path = state. path . clone ( ) + "/godot" ;
75
73
spawn ( move || {
76
74
let output = Command :: new ( "scons" )
77
75
. arg ( "--help" )
78
- . current_dir ( "D:/Godot/test/godot" )
76
+ . current_dir ( path )
79
77
. output ( )
80
78
. unwrap ( ) ;
81
79
0 commit comments