create block/unblock buttons more idiomatically
This commit is contained in:
+38
-35
@@ -168,41 +168,44 @@ impl App {
|
|||||||
self.game_networking.reset_indicator_if_failed();
|
self.game_networking.reset_indicator_if_failed();
|
||||||
label
|
label
|
||||||
});
|
});
|
||||||
ui.horizontal(|ui| {
|
ui.allocate_ui_with_layout(
|
||||||
let available_width = label.inner.rect.width();
|
egui::vec2(label.inner.rect.width(), 0.0),
|
||||||
let spacing = ui.spacing().item_spacing.x;
|
egui::Layout::top_down(egui::Align::Min),
|
||||||
let button_width = (available_width - spacing) / 2.0;
|
|ui| {
|
||||||
if ui
|
ui.columns(2, |columns| {
|
||||||
.add_sized([button_width, 18.0], egui::Button::new("Block"))
|
columns[0].vertical_centered_justified(|ui| {
|
||||||
.clicked()
|
if ui.button("Block").clicked() {
|
||||||
{
|
match self.settings.block_method {
|
||||||
match self.settings.block_method {
|
BlockMethod::EntireGame => {
|
||||||
BlockMethod::EntireGame => {
|
self.game_networking
|
||||||
self.game_networking
|
.block_exe(&mut self.system_info)
|
||||||
.block_exe(&mut self.system_info)
|
.unwrap();
|
||||||
.unwrap();
|
}
|
||||||
}
|
BlockMethod::SaveServer => {
|
||||||
BlockMethod::SaveServer => {
|
self.game_networking
|
||||||
self.game_networking
|
.block_save_server(
|
||||||
.block_save_server(&self.settings.save_server_ip)
|
&self.settings.save_server_ip,
|
||||||
.unwrap();
|
)
|
||||||
}
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ui
|
}
|
||||||
.add_sized([button_width, 18.0], egui::Button::new("Unblock"))
|
});
|
||||||
.clicked()
|
columns[1].vertical_centered_justified(|ui| {
|
||||||
{
|
if ui.button("Unblock").clicked() {
|
||||||
match self.settings.block_method {
|
match self.settings.block_method {
|
||||||
BlockMethod::EntireGame => {
|
BlockMethod::EntireGame => {
|
||||||
self.game_networking.unblock_exe().unwrap();
|
self.game_networking.unblock_exe().unwrap();
|
||||||
}
|
}
|
||||||
BlockMethod::SaveServer => {
|
BlockMethod::SaveServer => {
|
||||||
self.game_networking.unblock_save_server().unwrap();
|
self.game_networking.unblock_save_server().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
},
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.response
|
.response
|
||||||
.on_disabled_hover_text("This requires administrator.\nUse the Elevate button.");
|
.on_disabled_hover_text("This requires administrator.\nUse the Elevate button.");
|
||||||
|
|||||||
Reference in New Issue
Block a user