mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Add end run button to settings screen as well.
This commit is contained in:
parent
f454e6919c
commit
5f1b0e6eff
1 changed files with 38 additions and 25 deletions
|
@ -474,6 +474,38 @@ enum PlayerPicker {
|
||||||
PlayerForearm,
|
PlayerForearm,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct EndRunButton {
|
||||||
|
end_run_confirmation: bool,
|
||||||
|
}
|
||||||
|
impl EndRunButton {
|
||||||
|
fn show(&mut self, ui: &mut Ui, netman: &mut NetManStopOnDrop) {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
let dirty = netman.dirty.load(Ordering::Relaxed);
|
||||||
|
let button = Button::new(tr("launcher_end_run"))
|
||||||
|
.small()
|
||||||
|
.fill(Color32::LIGHT_RED);
|
||||||
|
if !self.end_run_confirmation
|
||||||
|
&& if dirty {
|
||||||
|
ui.add(button).clicked()
|
||||||
|
} else {
|
||||||
|
ui.button(tr("launcher_end_run")).clicked()
|
||||||
|
}
|
||||||
|
{
|
||||||
|
self.end_run_confirmation = true
|
||||||
|
} else if self.end_run_confirmation
|
||||||
|
&& ui.button(tr("launcher_end_run_confirm")).clicked()
|
||||||
|
{
|
||||||
|
self.end_run_confirmation = false;
|
||||||
|
netman.end_run.store(true, Ordering::Relaxed);
|
||||||
|
};
|
||||||
|
if dirty {
|
||||||
|
ui.label("PENDING SETTINGS NOT SET UNTIL RUN ENDS");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
state: AppState,
|
state: AppState,
|
||||||
modmanager: Modmanager,
|
modmanager: Modmanager,
|
||||||
|
@ -488,7 +520,7 @@ pub struct App {
|
||||||
/// `true` if we haven't started noita automatically yet.
|
/// `true` if we haven't started noita automatically yet.
|
||||||
can_start_automatically: bool,
|
can_start_automatically: bool,
|
||||||
player_image: RgbaImage,
|
player_image: RgbaImage,
|
||||||
end_run_confirmation: bool,
|
end_run_button: EndRunButton,
|
||||||
appearance: PlayerAppearance,
|
appearance: PlayerAppearance,
|
||||||
connected_menu: ConnectedMenu,
|
connected_menu: ConnectedMenu,
|
||||||
show_host_settings: bool,
|
show_host_settings: bool,
|
||||||
|
@ -625,7 +657,7 @@ impl App {
|
||||||
can_start_automatically: false,
|
can_start_automatically: false,
|
||||||
run_save_state,
|
run_save_state,
|
||||||
player_image,
|
player_image,
|
||||||
end_run_confirmation: false,
|
end_run_button: EndRunButton::default(),
|
||||||
appearance,
|
appearance,
|
||||||
connected_menu: ConnectedMenu::Normal,
|
connected_menu: ConnectedMenu::Normal,
|
||||||
show_host_settings: false,
|
show_host_settings: false,
|
||||||
|
@ -1252,29 +1284,9 @@ impl App {
|
||||||
|
|
||||||
if netman.peer.is_host() {
|
if netman.peer.is_host() {
|
||||||
ui.add_space(15.0);
|
ui.add_space(15.0);
|
||||||
ui.horizontal(|ui| {
|
|
||||||
let dirty = netman.dirty.load(Ordering::Relaxed);
|
self.end_run_button.show(ui, netman);
|
||||||
let button = Button::new(tr("launcher_end_run"))
|
|
||||||
.small()
|
|
||||||
.fill(Color32::LIGHT_RED);
|
|
||||||
if !self.end_run_confirmation
|
|
||||||
&& if dirty {
|
|
||||||
ui.add(button).clicked()
|
|
||||||
} else {
|
|
||||||
ui.button(tr("launcher_end_run")).clicked()
|
|
||||||
}
|
|
||||||
{
|
|
||||||
self.end_run_confirmation = true
|
|
||||||
} else if self.end_run_confirmation
|
|
||||||
&& ui.button(tr("launcher_end_run_confirm")).clicked()
|
|
||||||
{
|
|
||||||
self.end_run_confirmation = false;
|
|
||||||
netman.end_run.store(true, Ordering::Relaxed);
|
|
||||||
};
|
|
||||||
if dirty {
|
|
||||||
ui.label("PENDING SETTINGS NOT SET UNTIL RUN ENDS");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ui.add_space(15.0);
|
ui.add_space(15.0);
|
||||||
let mut temp = netman.no_more_players.load(Ordering::Relaxed);
|
let mut temp = netman.no_more_players.load(Ordering::Relaxed);
|
||||||
if ui
|
if ui
|
||||||
|
@ -1308,6 +1320,7 @@ impl App {
|
||||||
}
|
}
|
||||||
ConnectedMenu::Settings => {
|
ConnectedMenu::Settings => {
|
||||||
self.app_saved_state.game_settings.show_editor(ui);
|
self.app_saved_state.game_settings.show_editor(ui);
|
||||||
|
self.end_run_button.show(ui, netman);
|
||||||
}
|
}
|
||||||
ConnectedMenu::ConnectionInfo => match &netman.peer {
|
ConnectedMenu::ConnectionInfo => match &netman.peer {
|
||||||
PeerVariant::Tangled(_) => {
|
PeerVariant::Tangled(_) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue