Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions locales/zh-tw.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2839,3 +2839,46 @@ Click a 2nd reference point on the object, or Esc to finish 點擊物件上的
Aligned angle! (Ctrl+Z to undo) 已對齊角度!(Ctrl+Z 復原)
Vertex snap complete 頂點吸附完成
Align vertex angle 對齊頂點角度
Kerb height 路緣高度
Strips run from left to right 積木依道路左至右排列
Lane 行車線
Median 分隔帶
BusBay 巴士停車灣
Forward ↑ 順向 ↑
Backward ↓ 逆向 ↓
bus only 巴士專用
Use roadway texture 與行車道相同
Choose file… 選擇檔案…
Default footway texture 預設行人路貼圖
Advanced: strip mode 進階:積木模式
This road was made for left-hand traffic 此道路是為靠左行駛建立的
This road was made for right-hand traffic 此道路是為靠右行駛建立的
This road contains settings that simple mode cannot represent 此道路含簡單模式無法表示的設定
Built-in multi-lane texture markings may not align with these lanes 內建多行車線貼圖的標線可能與行車線不符
Lane widths differ 行車線闊度不一致
Contains bus-only lanes 含巴士專用行車線
Contains multiple medians 含多個分隔帶
Median is not between opposite directions 分隔帶不在兩個行車方向的交界
Contains a left BusBay 左側含巴士停車灣
Footway textures differ 兩側行人路使用不同貼圖
Names must not contain _bay_ (reserved for the bus bay tool) 名稱不能包含 _bay_(保留給巴士停車灣工具產生的道路類型)
A road needs at least one Lane 道路至少需要一條行車線
Strip {} has an invalid width 積木 {} 的闊度無效
Footways must be at the outer ends 行人路只能位於道路兩端
BusBays must border the roadway, at most one per side 巴士停車灣只能緊貼行車道外緣,每側最多一個
Medians must be inside the roadway 分隔帶必須位於行車道內
The roadway may contain only Lanes and Medians 行車道內只能包含行車線和分隔帶
Lane directions do not match this road’s traffic side 行車線方向排列不符合此道路的行駛側設定
Reset bay texture 重設停車灣貼圖
Bay texture reset 已重設停車灣貼圖
Could not reset bay texture 無法重設停車灣貼圖
The roadway texture is missing 找不到行車道貼圖
The roadway texture could not be read 無法讀取行車道貼圖
Apply bus lane rules to all existing roads 套用巴士專用規則到所有現有道路
Road types and spline counts to update 將套用的道路類型與 spline 數量
Rules added 新增規則數量
Roads changed; review the preview again 道路已變更,請重新檢查預覽
No roads need bus lane rules 沒有需要套用巴士專用規則的道路
BUS 巴士
No footway texture 未設定行人路貼圖
Road metadata not found 找不到道路製作器資料檔
1 change: 1 addition & 0 deletions src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,7 @@ mod tests {

fn doc_with(tiles: &[TileKey]) -> Document {
let mut doc = Document {
content_root: None,
global: Default::default(),
tiles: Default::default(),
order: Vec::new(),
Expand Down
2 changes: 2 additions & 0 deletions src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ pub fn paste(doc: &mut Document, clip: &Clip, at: DVec3) -> Vec<Sel> {
t.touch_content();
out.push(Sel::Spline(k, ids[&c.s.id]));
}
let made: Vec<_> = out.iter().filter_map(|s| if let Sel::Spline(k, id) = s { Some((*k, *id)) } else { None }).collect();
crate::road_maker::bus_rules::apply_for_splines(doc, &made, "clipboard::paste");
// what hangs on them, in order (a parent comes before what hangs on it)
for a in &clip.attached {
let Some(pid) = a.parent_id else { continue };
Expand Down
1 change: 1 addition & 0 deletions src/collab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ fn guest_doc(roots: &Roots, w: &Welcome) -> Result<Document, String> {
/// An empty document to fill.
fn placeholder() -> Document {
Document {
content_root: None,
global: Default::default(),
tiles: Default::default(),
order: Vec::new(),
Expand Down
2 changes: 2 additions & 0 deletions src/doc/autosave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub struct Snapshot {
/// Copy what an autosave of the map writes.
pub fn snapshot(doc: &Document) -> Snapshot {
let copy = Document {
content_root: doc.content_root.clone(),
global: doc.global.clone(),
tiles: doc.tiles.iter().filter(|(_, t)| t.dirty).map(|(k, t)| (*k, t.clone())).collect(),
order: doc.order.clone(),
Expand Down Expand Up @@ -327,6 +328,7 @@ mod tests {
let content = std::env::temp_dir().join(format!("openmapper-test-autosave-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&content);
let mut doc = Document {
content_root: None,
global: Default::default(),
tiles: Default::default(),
order: Vec::new(),
Expand Down
6 changes: 6 additions & 0 deletions src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ pub enum Sel {

/// The map.
pub struct Document {
/// Active editor content root, independent of the map save location.
pub content_root: Option<PathBuf>,
pub global: GlobalCfg,
pub tiles: BTreeMap<TileKey, TileDoc>,
/// The `[map]` list in file order: entry points and repeaters name tiles by their place
Expand Down Expand Up @@ -241,6 +243,7 @@ impl Document {
omsi_map::set_world_coordinates(false);
omsi_map::set_tile_size(omsi_map::TILE_SIZE);
let mut doc = Document {
content_root: Some(roots.content.clone()),
global,
tiles: BTreeMap::new(),
order: Vec::new(),
Expand Down Expand Up @@ -336,6 +339,7 @@ impl Document {
progress(1.0);
crate::render::profile::log_time(&format!("read {} tiles", tiles.len()), started);
Ok(Document {
content_root: Some(roots.content.clone()),
global,
tiles,
order,
Expand Down Expand Up @@ -388,6 +392,7 @@ impl Document {
/// and chrono patches, which take room and are not looked at.
pub fn for_reading(&self) -> Document {
Document {
content_root: self.content_root.clone(),
global: self.global.clone(),
tiles: self.tiles.iter().map(|(k, t)| (*k, TileDoc { tile: t.tile.clone(), terrain: t.terrain.clone(), masks: Vec::new(), chrono: Vec::new(), water: t.water, terrain_rev: t.terrain_rev, mask_rev: t.mask_rev, content_rev: t.content_rev, dirty: t.dirty })).collect(),
order: self.order.clone(),
Expand Down Expand Up @@ -722,6 +727,7 @@ impl Document {
}
}
}
crate::road_maker::bus_rules::apply_for_splines(self, &[(k, new)], "doc::split_spline");
Some(new)
}

Expand Down
1 change: 1 addition & 0 deletions src/doc/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub(crate) fn prepare_save(doc: &Document) -> SaveJob {
source: doc.source.clone(),
};
let copy = Document {
content_root: doc.content_root.clone(),
global: doc.global.clone(),
tiles: doc
.tiles
Expand Down
1 change: 1 addition & 0 deletions src/doc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) fn sample_map(roots: &Roots) -> Document {
GroundTex { texture: "Texture\\sand.bmp".into(), detail_texture: "Texture\\noise_low.bmp".into(), params: [8.0, 16.0, 4.0] },
];
let mut doc = Document {
content_root: None,
global,
tiles: Default::default(),
order: Vec::new(),
Expand Down
2 changes: 2 additions & 0 deletions src/ed_cjunction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ fn lay_connector(doc: &mut Document, at: (TileKey, i64, bool), file: &str, from:
});
t.touch_content();
}
let made: Vec<_> = ordered.iter().zip(&ids).map(|((s, _), id)| (tile_of(s.start), *id)).collect();
crate::road_maker::bus_rules::apply_for_splines(doc, &made, "ed_cjunction::lay_connector");
// the road's end takes the link
if let Some(t) = doc.tiles.get_mut(&at.0) {
if let Some(s) = t.tile.splines.iter_mut().find(|s| s.id == at.1) {
Expand Down
39 changes: 22 additions & 17 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,7 @@ impl Editor {
self.paint_layer = if doc.global.ground_textures.len() > 1 { 1 } else { 0 };
self.session_first_id = doc.global.next_id_code;
let mut doc = doc;
if self.content_dir.is_some() { doc.content_root = self.content_dir.clone(); }
doc.groups = crate::mapgroups::load(&doc.dir);
if let Some(content) = self.content_dir.as_deref() {
doc.signal_sets.reload(&doc.dir, content);
Expand Down Expand Up @@ -4597,6 +4598,8 @@ impl Editor {
t.touch_content();
made.push((k, ids[i]));
}
if self.content_dir.is_some() { doc.content_root = self.content_dir.clone(); }
crate::road_maker::bus_rules::apply_for_splines(doc, &made, "editor::lay_road");
// link the ends to what they meet (whether it is still there with that end free: a
// one-sided link would point at nothing)
let link = |doc: &mut Document, at: Option<(TileKey, i64, bool)>, mine: i64| -> bool {
Expand Down Expand Up @@ -6588,6 +6591,8 @@ impl Editor {
let t = doc.tiles.get_mut(&nk).unwrap();
t.tile.splines.push(q);
t.touch_content();
if self.content_dir.is_some() { doc.content_root = self.content_dir.clone(); }
crate::road_maker::bus_rules::apply_for_splines(doc, &[(nk, nid)], "editor::continue_spline");
self.finish_step();
self.select(Some(Sel::Spline(nk, nid)));
true
Expand Down Expand Up @@ -7470,6 +7475,8 @@ impl Editor {
let t = doc.tiles.get_mut(&k).unwrap();
t.tile.splines.push(sp);
t.touch_content();
if self.content_dir.is_some() { doc.content_root = self.content_dir.clone(); }
crate::road_maker::bus_rules::apply_for_splines(doc, &[(k, ids[i])], "editor::connect_path_points");
}
}
let (next, prev) = if ids.is_empty() { (to.1, from.1) } else { (ids[0], *ids.last().unwrap()) };
Expand Down Expand Up @@ -8251,20 +8258,12 @@ impl Editor {

/// Give every selected spline another type.
pub fn retype_splines(&mut self, file: &str) {
let sels = self.selection();
let splines: Vec<_> = self.selection().into_iter().filter_map(|s| if let Sel::Spline(k, id) = s { Some((k, id)) } else { None }).collect();
let Some(doc) = self.doc.as_mut() else { return };
self.history.begin(tr("Change road type", "Смена типа дороги"));
for s in &sels {
if let Sel::Spline(k, id) = *s {
self.history.touch_tile(doc, k);
if let Some(t) = doc.tiles.get_mut(&k) {
if let Some(sp) = t.tile.splines.iter_mut().find(|x| x.id == id) {
sp.file = file.to_string();
}
t.touch_content();
}
}
}
for &(key, _) in &splines { self.history.touch_tile(doc, key); }
if self.content_dir.is_some() { doc.content_root = self.content_dir.clone(); }
crate::road_maker::bus_rules::retype(doc, &splines, file, "editor::retype_splines");
self.history.commit();
}

Expand Down Expand Up @@ -9611,17 +9610,17 @@ impl Editor {
continue;
}
self.history.touch_tile(doc, k);
let t = doc.tiles.get_mut(&k).unwrap();
if splines {
for s in t.tile.splines.iter_mut().filter(|s| !s.deleted && s.file.eq_ignore_ascii_case(from)) {
s.file = to.to_string();
}
let instances: Vec<_> = doc.tiles[&k].tile.splines.iter().filter(|s| !s.deleted && s.file.eq_ignore_ascii_case(from)).map(|s| (k, s.id)).collect();
if self.content_dir.is_some() { doc.content_root = self.content_dir.clone(); }
crate::road_maker::bus_rules::retype(doc, &instances, to, "editor::replace_everywhere");
} else {
let t = doc.tiles.get_mut(&k).unwrap();
for o in t.tile.objects.iter_mut().chain(t.tile.attach_objects.iter_mut()).filter(|o| o.file.eq_ignore_ascii_case(from)) {
o.file = to.to_string();
}
}
t.touch_content();
doc.tiles.get_mut(&k).unwrap().touch_content();
n += here;
}
self.history.commit();
Expand Down Expand Up @@ -10896,6 +10895,7 @@ fn join_arms(doc: &mut Document, a: &crate::junction::Arm, b: &crate::junction::
t.touch_content();
ids.push((k, id));
}
crate::road_maker::bus_rules::apply_for_splines(doc, &ids, "editor::join_arms");
// link the chain: a's end -> new pieces -> b's end
let set = |doc: &mut Document, k: TileKey, id: i64, at_end: bool, other: i64| {
if let Some(t) = doc.tiles.get_mut(&k) {
Expand Down Expand Up @@ -17048,3 +17048,8 @@ mod tests {
assert!((o.rot[0] - 270.0).abs() < 1e-4);
}
}

#[cfg(test)]
mod bus_lane_tests;

mod bus_rule_batch;
Loading
Loading