Skip to content

Commit

Permalink
put colors in lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Feb 3, 2024
1 parent 7200ac7 commit 0abecfc
Show file tree
Hide file tree
Showing 32 changed files with 317 additions and 243 deletions.
92 changes: 0 additions & 92 deletions assets/config.json

This file was deleted.

83 changes: 83 additions & 0 deletions base_mod/colors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

data:extend {
type = "colors",
name = "colors",
label = "Colors",

sand_col = {
r = 0.5411765,
g = 0.49019608,
b = 0.3019608,
},
sea_col = {
r = 0.20896202,
g = 0.39679408,
b = 0.47983873,
},
roof_col = {
r = 0.2627451,
g = 0.21314174,
b = 0.12673587,
},
house_col = {
r = 1.0,
g = 1.0,
b = 1.0,
},
gui_success = {
r = 0.3,
g = 0.8,
b = 0.3,
},
gui_danger = {
r = 0.85,
g = 0.3,
b = 0.3,
},
gui_primary = {
r = 0.29411766,
g = 0.39607844,
b = 1.0,
},
gui_disabled = {
r = 0.79607844,
g = 0.79607844,
b = 0.79607844,
a = 0.2
},
road_low_col = {
r = 0.21568628,
g = 0.21568628,
b = 0.21568628,
},
road_mid_col = {
r = 0.3019608,
g = 0.3019608,
b = 0.3019608,
},
road_hig_col = {
r = 0.42,
g = 0.42,
b = 0.42,
},
road_line_col = {
r = 0.50980395,
g = 0.50980395,
b = 0.50980395,
},
road_pylon_col = {
r = 0.48789835,
g = 0.4879001,
b = 0.48790324,
},
lot_unassigned_col = {
r = 0.20392157,
g = 0.4509804,
b = 0.17254902,
},
lot_residential_col = {
r = 0.2,
g = 0.6,
b = 0.25,
}
}
1 change: 1 addition & 0 deletions base_mod/data.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require("items")
require("companies")
require("leisure")
require("colors")

data:extend {
{
Expand Down
3 changes: 1 addition & 2 deletions native_app/src/game_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,9 @@ impl State {
.then(|| self.uiw.read::<TerraformingResource>().radius)
.unwrap_or_default();
drop(camera);
let c = simulation::config();
let c = simulation::colors();
params.sand_col = c.sand_col.into();
params.sea_col = c.sea_col.into();
drop(c);
}

fn manage_io(&mut self, ctx: &mut Context) {
Expand Down
24 changes: 0 additions & 24 deletions native_app/src/gui/windows/config.rs

This file was deleted.

2 changes: 0 additions & 2 deletions native_app/src/gui/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::inputmap::{InputAction, InputMap};
use crate::uiworld::UiWorld;
use simulation::Simulation;

mod config;
pub mod debug;
mod economy;
pub mod load;
Expand Down Expand Up @@ -59,7 +58,6 @@ impl Default for GUIWindows {
opened: vec![],
};
s.insert("Economy", economy::economy, false);
s.insert("Config", config::config, false);
s.insert("Debug", debug::debug, false);
s.insert("Settings", settings::settings, false);
#[cfg(feature = "multiplayer")]
Expand Down
6 changes: 3 additions & 3 deletions native_app/src/newgui/tools/addtrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn addtrain(sim: &Simulation, uiworld: &mut UiWorld) {
Some(x) => x,
None => {
draw.circle(mpos, 10.0)
.color(simulation::config().gui_danger);
.color(simulation::colors().gui_danger);
return;
}
};
Expand All @@ -52,11 +52,11 @@ pub fn addtrain(sim: &Simulation, uiworld: &mut UiWorld) {
};

if dist <= trainlength {
drawtrain(simulation::config().gui_danger);
drawtrain(simulation::colors().gui_danger);
return;
}

drawtrain(simulation::config().gui_primary);
drawtrain(simulation::colors().gui_primary);

let cmd = WorldCommand::AddTrain {
dist,
Expand Down
4 changes: 2 additions & 2 deletions native_app/src/newgui/tools/bulldozer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ pub fn bulldozer(sim: &Simulation, uiworld: &mut UiWorld) {
cur_proj.kind,
ProjectKind::Inter(_) | ProjectKind::Road(_) | ProjectKind::Building(_)
) {
simulation::config().gui_danger
simulation::colors().gui_danger
} else {
simulation::config().gui_disabled
simulation::colors().gui_disabled
};

draw.circle(cur_proj.pos.up(0.5), 2.0).color(col);
Expand Down
2 changes: 1 addition & 1 deletion native_app/src/newgui/tools/inspected_aura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ pub fn inspected_aura(sim: &Simulation, uiworld: &mut UiWorld) {
}

draw.obb(b.obb, b.height + 0.01)
.color(simulation::config().gui_primary);
.color(simulation::colors().gui_primary);
}
}
4 changes: 2 additions & 2 deletions native_app/src/newgui/tools/lotbrush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub fn lotbrush(sim: &Simulation, uiworld: &mut UiWorld) {
let kind = res.kind;

let mut col = match kind {
LotKind::Unassigned => simulation::config().lot_unassigned_col,
LotKind::Residential => simulation::config().lot_residential_col,
LotKind::Unassigned => simulation::colors().lot_unassigned_col,
LotKind::Residential => simulation::colors().lot_residential_col,
};

col.a = 0.2;
Expand Down
6 changes: 3 additions & 3 deletions native_app/src/newgui/tools/roadbuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn roadbuild(sim: &Simulation, uiworld: &mut UiWorld) {
if state.snap_to_grid && log_camheight < cutoff {
let alpha = 1.0 - log_camheight / cutoff;
let col = simulation::config().gui_primary.a(alpha);
let col = simulation::colors().gui_primary.a(alpha);
let screen = AABB::new(unproj.xy(), unproj.xy()).expand(300.0);
let startx = (screen.ll.x / grid_size).ceil() * grid_size;
let starty = (screen.ll.y / grid_size).ceil() * grid_size;
Expand Down Expand Up @@ -394,9 +394,9 @@ impl RoadBuildResource {
let mut proj_pos = proj.pos;
proj_pos.z += 0.4;
let col = if is_valid {
simulation::config().gui_primary
simulation::colors().gui_primary
} else {
simulation::config().gui_danger
simulation::colors().gui_danger
};

let p = match self.build_state {
Expand Down
6 changes: 3 additions & 3 deletions native_app/src/newgui/tools/roadeditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ pub fn roadeditor(sim: &Simulation, uiworld: &mut UiWorld) {
if Some(id) != state.inspect.as_ref().map(|x| x.id) {
proj_pos = cur_proj.pos;
}
proj_col = simulation::config().gui_primary;
proj_col = simulation::colors().gui_primary;
} else {
proj_col = simulation::config().gui_disabled;
proj_col = simulation::colors().gui_disabled;
}

if inp.act.contains(&InputAction::Select) {
if let ProjectKind::Inter(id) = cur_proj.kind {
proj_col = simulation::config().gui_success;
proj_col = simulation::colors().gui_success;
proj_pos = cur_proj.pos;
let inter = &map.intersections()[id];
state.inspect = Some(IntersectionComponent {
Expand Down
4 changes: 2 additions & 2 deletions native_app/src/newgui/tools/specialbuilding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ pub fn specialbuilding(sim: &Simulation, uiworld: &mut UiWorld) {
let mut draw = |obb, red| {
let p = asset.to_string();
let col = if red {
simulation::config().gui_danger.adjust_luminosity(1.3)
simulation::colors().gui_danger.adjust_luminosity(1.3)
} else {
simulation::config()
simulation::colors()
.gui_primary
.adjust_luminosity(tweak!(1.5))
};
Expand Down
4 changes: 2 additions & 2 deletions native_app/src/newgui/tools/terraforming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn terraforming(sim: &Simulation, uiworld: &mut UiWorld) {
),
res.level.unwrap_or(mpos.z) - 0.5,
)
.color(simulation::config().gui_primary.a(0.2));
.color(simulation::colors().gui_primary.a(0.2));
}
}
TerraformKind::Slope => {
Expand All @@ -130,7 +130,7 @@ pub fn terraforming(sim: &Simulation, uiworld: &mut UiWorld) {
} else {
draw.line(res.slope_start.unwrap(), res.slope_end.unwrap(), res.radius)
}
.color(simulation::config().gui_primary.a(0.2));
.color(simulation::colors().gui_primary.a(0.2));
}
TerraformKind::Erode => {}
}
Expand Down
8 changes: 4 additions & 4 deletions native_app/src/newgui/tools/zoneedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ pub fn zoneedit(sim: &Simulation, uiworld: &mut UiWorld) {
let base_col = if !isvalid {
uiworld.write::<ErrorTooltip>().msg = Some(Cow::Owned(invalidmsg));
uiworld.write::<ErrorTooltip>().isworld = true;
simulation::config().gui_danger
simulation::colors().gui_danger
} else {
simulation::config().gui_primary
simulation::colors().gui_primary
};

for (p1, p2) in newpoly.iter().zip(newpoly.iter().cycle().skip(1)) {
Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn zoneedit(sim: &Simulation, uiworld: &mut UiWorld) {
for (i, &p) in newpoly.iter().enumerate() {
if Some((i, p, false)) == closest {
draw.circle(p.z(1.1), 6.0)
.color(simulation::config().gui_success);
.color(simulation::colors().gui_success);
continue;
}

Expand All @@ -139,7 +139,7 @@ pub fn zoneedit(sim: &Simulation, uiworld: &mut UiWorld) {
for (i, p) in newpoly.segments().map(|s| s.center()).enumerate() {
if Some((i, p, true)) == closest {
draw.circle(p.z(1.1), 3.0)
.color(simulation::config().gui_success);
.color(simulation::colors().gui_success);
continue;
}

Expand Down
Loading

0 comments on commit 0abecfc

Please sign in to comment.