Skip to content

Commit

Permalink
Wall width
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmoenig committed Dec 11, 2024
1 parent f716231 commit 5b86330
Show file tree
Hide file tree
Showing 11 changed files with 618 additions and 236 deletions.
2 changes: 1 addition & 1 deletion StarterProject.eldiron

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion creator/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ impl TheTrait for Editor {
ctx.ui.send(TheEvent::SetStatusText(
TheId::empty(),
"Project loaded successfully.".to_string(),
))
));
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions creator/src/mapeditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,12 @@ impl MapEditor {
}
}

for linedef_id in &region.map.selected_linedefs {
if !linedef_ids.contains(linedef_id) {
linedef_ids.push(*linedef_id);
}
}

for linedef_id in linedef_ids {
if let Some(linedef) = region.map.find_linedef_mut(linedef_id) {
linedef.texture = self.curr_tile_uuid;
Expand Down
125 changes: 92 additions & 33 deletions creator/src/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum SidebarMode {
Screen,
Asset,
Model,
Material,
//Material,
Node,
Debug,
Palette,
Expand Down Expand Up @@ -97,10 +97,12 @@ impl Sidebar {
model_sectionbar_button.set_text("Model".to_string());
model_sectionbar_button.set_status_text("Models");

/*
let mut material_sectionbar_button =
TheSectionbarButton::new(TheId::named("Material Section"));
material_sectionbar_button.set_text("Material".to_string());
material_sectionbar_button.set_status_text("Currently available Materials.");
*/

let mut node_sectionbar_button = TheSectionbarButton::new(TheId::named("Node Section"));
node_sectionbar_button.set_text("Node".to_string());
Expand All @@ -127,7 +129,7 @@ impl Sidebar {
vlayout.add_widget(Box::new(screen_sectionbar_button));
vlayout.add_widget(Box::new(asset_sectionbar_button));
vlayout.add_widget(Box::new(model_sectionbar_button));
vlayout.add_widget(Box::new(material_sectionbar_button));
//vlayout.add_widget(Box::new(material_sectionbar_button));
vlayout.add_widget(Box::new(node_sectionbar_button));
vlayout.add_widget(Box::new(debug_sectionbar_button));
vlayout.add_widget(Box::new(palette_sectionbar_button));
Expand Down Expand Up @@ -717,11 +719,24 @@ impl Sidebar {
model_list_header_canvas.set_widget(TheStatusbar::new(TheId::empty()));
let mut model_list_header_canvas_hlayout = TheHLayout::new(TheId::empty());
model_list_header_canvas_hlayout.set_background_color(None);

let mut model_add_button = TheTraybarButton::new(TheId::named("Model Add"));
model_add_button.set_icon_name("icon_role_add".to_string());
model_add_button.set_status_text("Add a new model.");

let mut model_remove_button = TheTraybarButton::new(TheId::named("Model Remove"));
model_remove_button.set_icon_name("icon_role_remove".to_string());
model_remove_button.set_status_text("Remove the current asset.");
model_remove_button.set_disabled(true);

let mut filter_text = TheText::new(TheId::empty());
filter_text.set_text("Filter".to_string());

model_list_header_canvas_hlayout.set_margin(vec4i(10, 1, 5, 1));
model_list_header_canvas_hlayout.set_padding(3);
model_list_header_canvas_hlayout.add_widget(Box::new(model_add_button));
model_list_header_canvas_hlayout.add_widget(Box::new(model_remove_button));
//toolbar_hlayout.add_widget(Box::new(TheHDivider::new(TheId::empty())));
model_list_header_canvas_hlayout.add_widget(Box::new(filter_text));
let mut filter_edit = TheTextLineEdit::new(TheId::named("Model Filter Edit"));
filter_edit.set_text("".to_string());
Expand Down Expand Up @@ -750,7 +765,7 @@ impl Sidebar {
stack_layout.add_canvas(model_canvas);

// Material UI

/*
let mut material_canvas = TheCanvas::default();
let mut material_list_canvas = TheCanvas::default();
Expand Down Expand Up @@ -789,6 +804,7 @@ impl Sidebar {
material_canvas.set_center(material_list_canvas);
stack_layout.add_canvas(material_canvas);
*/

// Node UI

Expand Down Expand Up @@ -1761,6 +1777,48 @@ impl Sidebar {
redraw = true;
}
}
}
// Regions Add
else if id.name == "Model Add" {
if let Some(list_layout) = ui.get_list_layout("Model List") {
let map = Map::default();

let mut item = TheListItem::new(TheId::named_with_id("Model Item", map.id));
item.set_text(map.name.clone());
item.set_state(TheWidgetState::Selected);
item.set_context_menu(Some(TheContextMenu {
items: vec![TheContextMenuItem::new(
"Rename Model...".to_string(),
TheId::named("Rename Model"),
)],
..Default::default()
}));
list_layout.deselect_all();
let id = item.id().clone();
list_layout.add_item(item, ctx);
ctx.ui
.send_widget_state_changed(&id, TheWidgetState::Selected);

server_ctx.clear();
server_ctx.curr_region = map.id;
project.models.insert(map.id, map);
server.set_project(project.clone());
}
} else if id.name == "Model Remove" {
if let Some(list_layout) = ui.get_list_layout("Model List") {
if let Some(selected) = list_layout.selected() {
list_layout.remove(selected.clone());
project.remove_model(&selected.uuid);
//self.apply_region(ui, ctx, None, server, &project.palette);
}
}
} else if id.name == "Model Item" {
for r in &project.regions {
if r.id == id.uuid {
//self.apply_region(ui, ctx, Some(r), server, &project.palette);
redraw = true;
}
}
} else if id.name == "Character Add" {
if let Some(list_layout) = ui.get_list_layout("Character List") {
let mut bundle = TheCodeBundle::new();
Expand Down Expand Up @@ -2441,7 +2499,7 @@ impl Sidebar {
SidebarMode::Model as usize,
));
redraw = true;
} else if id.name == "Material Section" && *state == TheWidgetState::Selected {
/* } else if id.name == "Material Section" && *state == TheWidgetState::Selected {
self.deselect_sections_buttons(ui, id.name.clone());
if let Some(widget) = ui
Expand All @@ -2457,7 +2515,7 @@ impl Sidebar {
self.stack_layout_id.clone(),
SidebarMode::Material as usize,
));
redraw = true;
redraw = true;*/
} else if id.name == "Node Section" && *state == TheWidgetState::Selected {
self.deselect_sections_buttons(ui, id.name.clone());

Expand Down Expand Up @@ -3577,34 +3635,35 @@ impl Sidebar {
/// Shows the filtered models of the project.
pub fn show_filtered_models(
&mut self,
ui: &mut TheUI,
ctx: &mut TheContext,
project: &Project,
server_ctx: &ServerContext,
_ui: &mut TheUI,
_ctx: &mut TheContext,
_project: &Project,
_server_ctx: &ServerContext,
) {
let mut filter_text = if let Some(widget) = ui
.canvas
.get_widget(Some(&"Model Filter Edit".to_string()), None)
{
widget.value().to_string().unwrap_or_default()
} else {
"".to_string()
};

let _filter_role = if let Some(widget) = ui
.canvas
.get_widget(Some(&"Model Filter Role".to_string()), None)
{
if let Some(drop_down_menu) = widget.as_drop_down_menu() {
drop_down_menu.selected_index()
} else {
0
}
} else {
0
};

filter_text = filter_text.to_lowercase();
// let mut filter_text = if let Some(widget) = ui
// .canvas
// .get_widget(Some(&"Model Filter Edit".to_string()), None)
// {
// widget.value().to_string().unwrap_or_default()
// } else {
// "".to_string()
// };

// let _filter_role = if let Some(widget) = ui
// .canvas
// .get_widget(Some(&"Model Filter Role".to_string()), None)
// {
// if let Some(drop_down_menu) = widget.as_drop_down_menu() {
// drop_down_menu.selected_index()
// } else {
// 0
// }
// } else {
// 0
// };

//filter_text = filter_text.to_lowercase();
/*
if let Some(layout) = ui.canvas.get_layout(Some(&"Model List".to_string()), None) {
if let Some(list_layout) = layout.as_list_layout() {
Expand Down Expand Up @@ -3642,7 +3701,7 @@ impl Sidebar {
}
}
}
}
}*/
//ui.select_first_list_item("Material List", ctx);
}

Expand Down
38 changes: 37 additions & 1 deletion creator/src/tools/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct SectorTool {
rectangle_undo_map: Map,
click_selected: bool,
drag_changed: bool,
wall_width: f32,
wall_height: f32,
}

Expand All @@ -23,6 +24,7 @@ impl Tool for SectorTool {
click_selected: false,
drag_changed: false,
rectangle_undo_map: Map::default(),
wall_width: 0.0,
wall_height: 0.0,
}
}
Expand Down Expand Up @@ -75,6 +77,17 @@ impl Tool for SectorTool {

if let Some(layout) = ui.get_hlayout("Game Tool Params") {
layout.clear();

let mut wall_width = TheTextLineEdit::new(TheId::named("Wall Width"));
wall_width.set_value(TheValue::Float(self.wall_width));
// opacity.set_default_value(TheValue::Float(1.0));
wall_width.set_info_text(Some("Wall Width".to_string()));
wall_width.set_range(TheValue::RangeF32(0.0..=4.0));
wall_width.set_continuous(true);
wall_width.limiter_mut().set_max_width(150);
wall_width.set_status_text("The wall width of the enclosing linedefs.");
layout.add_widget(Box::new(wall_width));

let mut wall_height = TheTextLineEdit::new(TheId::named("Wall Height"));
wall_height.set_value(TheValue::Float(self.wall_height));
// opacity.set_default_value(TheValue::Float(1.0));
Expand Down Expand Up @@ -341,14 +354,37 @@ impl Tool for SectorTool {
_ui: &mut TheUI,
_ctx: &mut TheContext,
project: &mut Project,
_server: &mut Server,
server: &mut Server,
_client: &mut Client,
server_ctx: &mut ServerContext,
) -> bool {
let mut redraw = false;
#[allow(clippy::single_match)]
match event {
TheEvent::ValueChanged(id, value) => {
if id.name == "Wall Width" {
if let Some(value) = value.to_f32() {
self.wall_width = value;

if let Some(region) = project.get_region_mut(&server_ctx.curr_region) {
let mut linedef_ids = Vec::new();
for sector_id in &region.map.selected_sectors {
if let Some(sector) = region.map.find_sector(*sector_id) {
linedef_ids.extend(&sector.linedefs);
}
}

for linedef_id in linedef_ids {
if let Some(linedef) = region.map.find_linedef_mut(linedef_id) {
linedef.wall_width = value;
}
}

server.update_region(region);
}
}
redraw = true;
}
if id.name == "Wall Height" {
if let Some(value) = value.to_f32() {
self.wall_height = value;
Expand Down
Loading

0 comments on commit 5b86330

Please sign in to comment.