Skip to content

Commit

Permalink
Bugfixes regarding screen setup on new projects
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmoenig committed Jun 24, 2023
1 parent 97984e1 commit f6ec694
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
2 changes: 2 additions & 0 deletions creator_lib/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,8 @@ impl Editor<'_> {

self.toolbar.widgets[0].text = self.asset.tileset.maps_names.clone();
self.toolbar.widgets[1].selected = true;

This comment has been minimized.

Copy link
@Silversilina

Silversilina Dec 12, 2023

23

self.game_render = None;
}

/// Switches the asset view to the current asset index
Expand Down
7 changes: 7 additions & 0 deletions creator_lib/src/editor/controlbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ impl Widget for ControlBar {

fn resize(&mut self, width: usize, _height: usize, _context: &ScreenContext) {
self.rect.2 = width;

let rect = self.rect;
self.widgets[7].set_rect((rect.2 - 100 - 200, rect.1, 80, rect.3));
self.widgets[8].set_rect((rect.2 - 100 - 100, rect.1, 80, rect.3));
self.widgets[9].set_rect((rect.2 - 110, rect.1, 80, rect.3));
}

fn draw(&mut self, frame: &mut [u8], anim_counter: usize, asset: &mut Asset, context: &mut ScreenContext) {
Expand Down Expand Up @@ -227,6 +232,8 @@ impl Widget for ControlBar {
_ = server.shutdown();
}

context.server = None;

for index in 0..self.widgets.len() {
if index != ControlWidgets::Play as usize {
self.widgets[index].state = WidgetState::Normal;
Expand Down
2 changes: 1 addition & 1 deletion creator_lib/src/editor/gameoptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl EditorOptions for GameOptions {

node_list.add_group_list(context.color_green, context.color_light_green, vec!["Behavior Tree".to_string(), "Expression".to_string(), "Script".to_string(), "Linear".to_string(), "Sequence".to_string()]);

node_list.add_group_list(context.color_blue, context.color_light_blue, vec![ "Screen".to_string(), "Widget".to_string() ]);
node_list.add_group_list(context.color_blue, context.color_light_blue, vec![ "Screen".to_string()/* "Widget".to_string()*/ ]);

node_list.set_rect(rect);
widgets.push(node_list);
Expand Down
12 changes: 12 additions & 0 deletions creator_lib/src/editor/nodegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,18 @@ impl EditorContent for NodeGraph {
node_widget.color = context.color_blue.clone();
node_widget.node_connector.insert(BehaviorNodeConnector::Top, NodeConnector { rect: (0,0,0,0) } );
node_widget.node_connector.insert(BehaviorNodeConnector::Bottom, NodeConnector { rect: (0,0,0,0) } );

// Check if the scripts and main.rai script exist and if not create it
let game_path = context.curr_project_path.join("game");
let scripts_path = game_path.join("scripts");
if fs::metadata(scripts_path.clone()).is_ok() == false {
if fs::create_dir(scripts_path.clone()).ok().is_some() {
if let Some(main) = context.scripts.get("screen") {
let path = scripts_path.join("main.rhai");
_ = fs::write(path, main);
}
}
}
} else
if node_behavior_type == BehaviorNodeType::Widget {
let mut atom1 = AtomWidget::new(vec!["Script".to_string()], AtomWidgetType::NodeScreenButton,
Expand Down
20 changes: 11 additions & 9 deletions creator_lib/src/editor/screeneditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,18 @@ impl EditorContent for ScreenEditor<'_> {

// Get the region the player is in

if let Some(behavior) = context.data.behaviors.get_mut(&context.data.behaviors_ids[0]) {
for (_id, node) in &behavior.data.nodes {
if node.behavior_type == BehaviorNodeType::BehaviorType {
if let Some(value )= node.values.get(&"position".to_string()) {
self.player_position = value.to_position();
if context.data.behaviors_ids.len() > 0 {
if let Some(behavior) = context.data.behaviors.get_mut(&context.data.behaviors_ids[0]) {
for (_id, node) in &behavior.data.nodes {
if node.behavior_type == BehaviorNodeType::BehaviorType {
if let Some(value )= node.values.get(&"position".to_string()) {
self.player_position = value.to_position();
}
if let Some(value )= node.values.get(&"tile".to_string()) {
self.player_tile = value.to_tile_id();
}
break;
}
if let Some(value )= node.values.get(&"tile".to_string()) {
self.player_tile = value.to_tile_id();
}
break;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions resources/scripts/region.rs

This file was deleted.

File renamed without changes.

0 comments on commit f6ec694

Please sign in to comment.