mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
removed refcell
This commit is contained in:
parent
5fc224f109
commit
ae35db731d
@ -144,4 +144,7 @@ pub trait PlayState {
|
||||
|
||||
/// Draw the play state.
|
||||
fn render<'a>(&'a self, drawer: &mut Drawer<'a>, settings: &Settings);
|
||||
|
||||
/// Determines whether egui will be rendered for this play state
|
||||
fn egui_enabled(&self) -> bool;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ pub struct CharSelectionState {
|
||||
char_selection_ui: CharSelectionUi,
|
||||
client: Rc<RefCell<Client>>,
|
||||
scene: Scene,
|
||||
need_shadow_clear: RefCell<bool>,
|
||||
}
|
||||
|
||||
impl CharSelectionState {
|
||||
@ -37,7 +36,6 @@ impl CharSelectionState {
|
||||
char_selection_ui,
|
||||
client,
|
||||
scene,
|
||||
need_shadow_clear: RefCell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +73,7 @@ impl PlayState for CharSelectionState {
|
||||
.set_scale_mode(global_state.settings.interface.ui_scale);
|
||||
|
||||
// Clear shadow textures since we don't render to them here
|
||||
*self.need_shadow_clear.borrow_mut() = true;
|
||||
global_state.window.clear_shadows_next_frame = true;
|
||||
}
|
||||
|
||||
fn tick(&mut self, global_state: &mut GlobalState, events: Vec<WinEvent>) -> PlayStateResult {
|
||||
@ -237,11 +235,6 @@ impl PlayState for CharSelectionState {
|
||||
fn globals_bind_group(&self) -> &GlobalsBindGroup { self.scene.global_bind_group() }
|
||||
|
||||
fn render<'a>(&'a self, drawer: &mut Drawer<'a>, _: &Settings) {
|
||||
if *self.need_shadow_clear.borrow() {
|
||||
drawer.clear_shadows();
|
||||
*self.need_shadow_clear.borrow_mut() = false;
|
||||
}
|
||||
|
||||
let client = self.client.borrow();
|
||||
let (humanoid_body, loadout) =
|
||||
Self::get_humanoid_body_inventory(&self.char_selection_ui, &client);
|
||||
@ -263,4 +256,6 @@ impl PlayState for CharSelectionState {
|
||||
self.char_selection_ui.render(&mut ui_drawer);
|
||||
};
|
||||
}
|
||||
|
||||
fn egui_enabled(&self) -> bool { false }
|
||||
}
|
||||
|
@ -332,6 +332,8 @@ impl PlayState for MainMenuState {
|
||||
self.main_menu_ui.render(&mut ui_drawer);
|
||||
};
|
||||
}
|
||||
|
||||
fn egui_enabled(&self) -> bool { false }
|
||||
}
|
||||
|
||||
fn get_client_msg_error(
|
||||
|
@ -179,19 +179,28 @@ fn handle_main_events_cleared(
|
||||
span!(guard, "Render");
|
||||
// Render the screen using the global renderer
|
||||
|
||||
let clear_shadows = global_state.window.clear_shadows_next_frame;
|
||||
if let Some(mut drawer) = global_state
|
||||
.window
|
||||
.renderer_mut()
|
||||
.start_recording_frame(last.globals_bind_group())
|
||||
.expect("Unrecoverable render error when starting a new frame!")
|
||||
{
|
||||
if clear_shadows {
|
||||
drawer.clear_shadows();
|
||||
}
|
||||
|
||||
last.render(&mut drawer, &global_state.settings);
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
if global_state.settings.interface.toggle_debug {
|
||||
if last.egui_enabled() && global_state.settings.interface.toggle_debug {
|
||||
span!(guard, "Draw egui");
|
||||
drawer.draw_egui(&mut global_state.egui_state.platform, scale_factor);
|
||||
}
|
||||
};
|
||||
if clear_shadows {
|
||||
global_state.window.clear_shadows_next_frame = false;
|
||||
}
|
||||
|
||||
drop(guard);
|
||||
}
|
||||
|
@ -1460,6 +1460,8 @@ impl PlayState for SessionState {
|
||||
self.hud.render(&mut ui_drawer);
|
||||
}; // Note: this semicolon is needed for the third_pass borrow to be dropped before it's lifetime ends
|
||||
}
|
||||
|
||||
fn egui_enabled(&self) -> bool { true }
|
||||
}
|
||||
|
||||
/// Max distance an entity can be "targeted"
|
||||
|
@ -544,6 +544,8 @@ pub struct Window {
|
||||
message_receiver: channel::Receiver<String>,
|
||||
// Used for screenshots & fullscreen toggle to deduplicate/postpone to after event handler
|
||||
take_screenshot: bool,
|
||||
// Used to clear the shadow textures when entering a PlayState that doesn't utilise shadows
|
||||
pub clear_shadows_next_frame: bool,
|
||||
toggle_fullscreen: bool,
|
||||
pub key_layout: Option<KeyLayout>,
|
||||
}
|
||||
@ -640,6 +642,7 @@ impl Window {
|
||||
message_sender,
|
||||
message_receiver,
|
||||
take_screenshot: false,
|
||||
clear_shadows_next_frame: false,
|
||||
toggle_fullscreen: false,
|
||||
key_layout,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user