Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translations #272

Merged
merged 5 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
File renamed without changes
7 changes: 5 additions & 2 deletions game/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ ggez = { git="https://github.com/ggez/ggez", branch="devel" }
serde = "1.0.145"
serde_yaml = "0.9.13"
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
tracing-subscriber = { version = "0.3.16", features = ['env-filter'] }
fastrand = "1.8.0"
chrono = "0.4.23"

[dev-dependencies]
tempdir = { version = "0.3.7" }

[build-dependencies]
fs_extra = "1.2.0"

Expand All @@ -23,4 +26,4 @@ codegen-units = 1

[profile.release]
lto = true
panic = "abort"
panic = "abort"
82 changes: 44 additions & 38 deletions game/src/backend/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
use crate::backend::rlcolor::RLColor;
use crate::game_core::player::gen_inventory;
use crate::game_core::resources::Resources;
use crate::languages::german::MACHINE_NAMES;
use crate::languages::{machine_names, Lang};
use crate::machines::machine::{Machine, State};
use crate::machines::trade::Trade;
use ggez::graphics::{Color, Rect};
use std::string::ToString;

/// Contains the screen resolution of the game.
/// The game is designed to be played in 1920x1080.
Expand Down Expand Up @@ -48,11 +47,12 @@ pub(crate) const SANDSTURM_CR: Resources<i16> = Resources {
/// Generates all machines with all their name, position, trades and resources.
/// # Returns
/// A Vector of `Machine`s
pub(crate) fn gen_all_machines() -> Vec<Machine> {
pub(crate) fn gen_all_machines(lng: Lang) -> Vec<Machine> {
vec![
// Oxygen machine
Machine::new_by_const((
MACHINE_NAMES[0].to_string(),
machine_names(lng)[0].into(),
machine_names(Lang::De)[0].into(),
Rect {
x: 280.0,
y: 230.0,
Expand All @@ -61,28 +61,28 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
},
vec![
Trade::new(
"repair_Oxygen".to_string(),
"repair_Oxygen".into(),
100,
State::Broken,
State::Idle,
false,
gen_inventory(2, 0, 0),
gen_inventory(2, 0, 0, lng),
),
Trade::new(
"start_Oxygen".to_string(),
"start_Oxygen".into(),
0,
State::Idle,
State::Running,
true,
gen_inventory(0, 0, 0),
gen_inventory(0, 0, 0, lng),
),
Trade::new(
"stop_Oxygen".to_string(),
"stop_Oxygen".into(),
0,
State::Running,
State::Idle,
true,
gen_inventory(0, 0, 0),
gen_inventory(0, 0, 0, lng),
),
],
Resources {
Expand All @@ -93,7 +93,8 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
)),
// Electricity machine
Machine::new_by_const((
MACHINE_NAMES[1].to_string(),
machine_names(lng)[1].into(),
machine_names(Lang::De)[1].into(),
Rect {
x: 282.0,
y: 752.0,
Expand All @@ -102,28 +103,28 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
},
vec![
Trade::new(
"fueling_Stromgenerator".to_string(),
"fueling_Stromgenerator".into(),
700,
State::Broken,
State::Running,
true,
gen_inventory(0, 1, 0),
gen_inventory(0, 1, 0, lng),
),
Trade::new(
"start_Stromgenerator".to_string(),
"start_Stromgenerator".into(),
1,
State::Idle,
State::Running,
true,
gen_inventory(0, 0, 0),
gen_inventory(0, 0, 0, lng),
),
Trade::new(
"stop_Stromgenerator".to_string(),
"stop_Stromgenerator".into(),
0,
State::Running,
State::Idle,
true,
gen_inventory(0, 0, 0),
gen_inventory(0, 0, 0, lng),
),
],
Resources {
Expand All @@ -134,7 +135,8 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
)),
// Worker machine
Machine::new_by_const((
MACHINE_NAMES[2].to_string(),
machine_names(lng)[2].into(),
machine_names(Lang::De)[2].into(),
Rect {
x: 1000.0,
y: 780.0,
Expand All @@ -143,20 +145,20 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
},
vec![
Trade::new(
"repair_werkermaschine".to_string(),
"repair_werkermaschine".into(),
100,
State::Broken,
State::Idle,
false,
gen_inventory(0, 0, 1),
gen_inventory(0, 0, 1, lng),
),
Trade::new(
"produce_superglue".to_string(),
"produce_superglue".into(),
120,
State::Idle,
State::Running,
true,
gen_inventory(-1, 0, 0),
gen_inventory(-1, 0, 0, lng),
),
],
Resources {
Expand All @@ -167,7 +169,8 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
)),
// 3d Printer machine
Machine::new_by_const((
MACHINE_NAMES[3].to_string(),
machine_names(lng)[3].into(),
machine_names(Lang::De)[3].into(),
Rect {
x: 930.0,
y: 230.0,
Expand All @@ -176,20 +179,20 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
},
vec![
Trade::new(
"repair_3d_printer".to_string(),
"repair_3d_printer".into(),
300,
State::Broken,
State::Idle,
false,
gen_inventory(2, 0, 0),
gen_inventory(2, 0, 0, lng),
),
Trade::new(
"produce_3d_teil".to_string(),
"produce_3d_teil".into(),
200,
State::Idle,
State::Running,
true,
gen_inventory(2, 0, -1),
gen_inventory(2, 0, -1, lng),
),
],
Resources {
Expand All @@ -200,7 +203,8 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
)),
// Communication module
Machine::new_by_const((
MACHINE_NAMES[4].to_string(),
machine_names(lng)[4].into(),
machine_names(Lang::De)[4].into(),
Rect {
x: 1640.0,
y: 320.0,
Expand All @@ -209,20 +213,20 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
},
vec![
Trade::new(
"Kommunikationsmodul_reparieren".to_string(),
"Kommunikationsmodul_reparieren".into(),
400,
State::Broken,
State::Idle,
false,
gen_inventory(5, 0, 3),
gen_inventory(5, 0, 3, lng),
),
Trade::new(
"Notfall_signal_absetzen".to_string(),
"Notfall_signal_absetzen".into(),
1000,
State::Idle,
State::Running,
true,
gen_inventory(1, 0, 1),
gen_inventory(1, 0, 1, lng),
),
],
Resources {
Expand All @@ -233,20 +237,21 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
)),
// First hole
Machine::new_by_const((
MACHINE_NAMES[5].to_string(),
machine_names(lng)[5].into(),
machine_names(Lang::De)[5].into(),
Rect {
x: 780.0,
y: 230.0,
w: 32.0,
h: 18.0,
},
vec![Trade::new(
"repair_Loch".to_string(),
"repair_Loch".into(),
100,
State::Running,
State::Idle,
false,
gen_inventory(2, 0, 0),
gen_inventory(2, 0, 0, lng),
)],
Resources {
oxygen: -15,
Expand All @@ -256,20 +261,21 @@ pub(crate) fn gen_all_machines() -> Vec<Machine> {
)),
// Second hole
Machine::new_by_const((
MACHINE_NAMES[6].to_string(),
machine_names(lng)[6].into(),
machine_names(Lang::De)[6].into(),
Rect {
x: 680.0,
y: 900.0,
w: 32.0,
h: 18.0,
},
vec![Trade::new(
"repair_Loch".to_string(),
"repair_Loch".into(),
100,
State::Running,
State::Idle,
false,
gen_inventory(2, 0, 0),
gen_inventory(2, 0, 0, lng),
)],
Resources {
oxygen: -15,
Expand Down
Loading