mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix Singleplayer
After a certains person's MR has been merged, for some reason all traces of working Singleplayer have disappeared Former-commit-id: 4119e4609cd39bb1896c7f28d45f5c1a7ec9c129
This commit is contained in:
parent
913bc042be
commit
40c2625a4c
@ -45,7 +45,10 @@ impl PlayState for CharSelectionState {
|
||||
// Handle window events
|
||||
for event in global_state.window.fetch_events() {
|
||||
match event {
|
||||
Event::Close => return PlayStateResult::Shutdown,
|
||||
Event::Close => {
|
||||
global_state.singleplayer = None;
|
||||
return PlayStateResult::Shutdown;
|
||||
},
|
||||
// Pass events to ui
|
||||
Event::Ui(event) => {
|
||||
self.char_selection_ui.handle_event(event);
|
||||
@ -60,7 +63,10 @@ impl PlayState for CharSelectionState {
|
||||
// Maintain the UI
|
||||
for event in self.char_selection_ui.maintain(global_state.window.renderer_mut()) {
|
||||
match event {
|
||||
ui::Event::Logout => return PlayStateResult::Pop,
|
||||
ui::Event::Logout => {
|
||||
global_state.singleplayer = None;
|
||||
return PlayStateResult::Pop;
|
||||
},
|
||||
ui::Event::Play => return PlayStateResult::Push(
|
||||
Box::new(SessionState::new(&mut global_state.window, self.client.clone()))
|
||||
),
|
||||
|
@ -5,6 +5,7 @@ use super::char_selection::CharSelectionState;
|
||||
use crate::{
|
||||
window::{Event, Window},
|
||||
GlobalState, PlayState, PlayStateResult,
|
||||
singleplayer::Singleplayer,
|
||||
};
|
||||
use client_init::{ClientInit, Error as InitError};
|
||||
use common::{clock::Clock, comp};
|
||||
@ -101,7 +102,10 @@ impl PlayState for MainMenuState {
|
||||
300,
|
||||
),
|
||||
)));
|
||||
}
|
||||
},
|
||||
MainMenuEvent::StartSingleplayer => {
|
||||
global_state.singleplayer = Some(Singleplayer::new());
|
||||
},
|
||||
MainMenuEvent::Quit => return PlayStateResult::Shutdown,
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ pub enum Event {
|
||||
username: String,
|
||||
server_address: String,
|
||||
},
|
||||
StartSingleplayer,
|
||||
Quit,
|
||||
}
|
||||
|
||||
@ -189,6 +190,20 @@ impl MainMenuUi {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
//Singleplayer
|
||||
//Used when the singleplayer button is pressed
|
||||
macro_rules! singleplayer {
|
||||
() => {
|
||||
self.login_error = None;
|
||||
events.push(Event::StartSingleplayer);
|
||||
events.push(Event::LoginAttempt {
|
||||
username: "singleplayer".to_string(),
|
||||
server_address: "localhost".to_string(),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
|
||||
// Username
|
||||
// TODO: get a lower resolution and cleaner input_bg.png
|
||||
@ -327,6 +342,7 @@ impl MainMenuUi {
|
||||
.set(self.ids.singleplayer_button, ui_widgets)
|
||||
.was_clicked()
|
||||
{
|
||||
singleplayer!();
|
||||
login!();
|
||||
}
|
||||
// Quit
|
||||
|
Loading…
Reference in New Issue
Block a user