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

Jsonize vehicle parts requiring other vehicle parts to be installed #37453

Merged
merged 32 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ff5c40a
jsonize vehicle part requir
Hirmuolio Jan 28, 2020
8e9af0b
json changes
Hirmuolio Jan 28, 2020
47e9802
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Jan 28, 2020
240aaf2
change json file
Hirmuolio Jan 28, 2020
e3f4764
remove test thing
Hirmuolio Jan 28, 2020
d184c3b
minor text changes
Hirmuolio Jan 28, 2020
444ae28
translate thing
Hirmuolio Jan 28, 2020
4e9b667
translate thing
Hirmuolio Jan 28, 2020
d425a6e
Update src/veh_type.h
Hirmuolio Jan 28, 2020
4c92f96
empty check
Hirmuolio Jan 28, 2020
2ba3b74
Update src/vehicle.cpp
Hirmuolio Jan 28, 2020
41d554f
translations.h
Hirmuolio Jan 28, 2020
9a8e1f6
extract_json_strings.py
Hirmuolio Jan 28, 2020
f9d19aa
documentation
Hirmuolio Feb 3, 2020
2b960cb
documentation
Hirmuolio Feb 3, 2020
a615253
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Feb 9, 2020
99a0d65
revert translation change
Hirmuolio Feb 9, 2020
67dcc17
revert translation change
Hirmuolio Feb 9, 2020
f145a24
display part that prevents removal
Hirmuolio Feb 11, 2020
9f0903e
remove stray thing
Hirmuolio Feb 11, 2020
77f0e31
remove stray thing
Hirmuolio Feb 11, 2020
5786bb4
period
Hirmuolio Feb 11, 2020
9408d11
change alternator flag
Hirmuolio Feb 12, 2020
3139799
remove unnecessary check
Hirmuolio Feb 12, 2020
72c842f
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Feb 12, 2020
8696724
adjust alternator flag
Hirmuolio Feb 12, 2020
65a2017
adjust alternator flag
Hirmuolio Feb 12, 2020
643ecf1
Merge branch 'Hirmuolio-vehicle-jsonize' of https://github.com/Hirmuo…
Hirmuolio Feb 12, 2020
eab295d
removed thing from doc
Hirmuolio Feb 12, 2020
32ca02d
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Mar 23, 2020
08971a2
rename window requiring flag
Hirmuolio Mar 26, 2020
bbe2b53
rename window requiring flag
Hirmuolio Mar 26, 2020
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
89 changes: 86 additions & 3 deletions data/json/vehicleparts/vp_flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"id": "ALTERNATOR",
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "An alternator. When mounted on a gasoline or diesel engine and the engine is on, will produce electrical power that can be stored in a battery."
"info": "An alternator. When mounted on a gasoline or diesel engine and the engine is on, will produce electrical power that can be stored in a battery.",
"requires_flag": "ENGINE",
"cant_remove": "Remove attached alternator first."
Hirmuolio marked this conversation as resolved.
Show resolved Hide resolved
},
{
"id": "AISLE",
Expand Down Expand Up @@ -65,6 +67,13 @@
"context": [ "vehicle_part" ],
"info": "Closed, it prevents people from seeing through the curtain. A door motor allows you to remotely open or close it from the vehicle controls."
},
{
"id": "WINDOW_CURTAIN",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WINDOW",
"cant_remove": "Remove attached curtains first."
},
{
"id": "DOOR",
"type": "json_flag",
Expand Down Expand Up @@ -123,7 +132,9 @@
"id": "SEATBELT",
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "This part will help prevent you from being thrown from the vehicle in a collision. You will automatically enable this part when you move into a tile with it."
"info": "This part will help prevent you from being thrown from the vehicle in a collision. You will automatically enable this part when you move into a tile with it.",
"requires_flag": "BELTABLE",
"cant_remove": "Remove attached seatbelt first."
},
{
"id": "STABLE",
Expand All @@ -141,7 +152,16 @@
"id": "TURRET",
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "A heavy weapon mounted in a turret. It can be fired from the vehicle controls."
"info": "A heavy weapon mounted in a turret. It can be fired from the vehicle controls.",
"requires_flag": "TURRET_MOUNT",
"cant_remove": "Remove attached mounted weapon first."
},
{
"id": "TURRET_CONTROLS",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "TURRET",
"cant_remove": "Remove attached turret controls first."
},
{
"id": "WHEEL",
Expand All @@ -160,5 +180,68 @@
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "You can craft here."
},
{
"id": "NEEDS_WHEEL_MOUNT_LIGHT",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WHEEL_MOUNT_LIGHT",
"cant_remove": "Remove attached wheel first."
},
{
"id": "NEEDS_WHEEL_MOUNT_MEDIUM",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WHEEL_MOUNT_MEDIUM",
"cant_remove": "Remove attached wheel first."
},
{
"id": "NEEDS_WHEEL_MOUNT_HEAVY",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WHEEL_MOUNT_HEAVY",
"cant_remove": "Remove attached wheel first."
},
{
"id": "NEEDS_BATTERY_MOUNT",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "BATTERY_MOUNT",
"cant_remove": "Remove battery from mount first."
},
{
"id": "ON_CONTROLS",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "CONTROLS",
"cant_remove": "Remove attached part first."
},
{
"id": "INTERNAL",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "CARGO",
"cant_remove": "Remove attached part first."
},
{
"id": "CARGO_LOCKING",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "LOCKABLE_CARGO",
"cant_remove": "Remove attached part first."
},
{
"id": "DOOR_MOTOR",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "OPENABLE",
"cant_remove": "Remove attached part first."
},
{
"id": "ON_ROOF",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "ROOF",
"cant_remove": "Remove attached part first."
}
]
3 changes: 3 additions & 0 deletions lang/extract_json_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,9 @@ def extract(item, infilename):
if "footsteps" in item:
writestr(outfile, item["footsteps"], **kwargs)
wrote = True
if "cant_remove" in item:
writestr(outfile, item["cant_remove"], **kwargs)
wrote = True
if not wrote and not "copy-from" in item:
if not warning_supressed(infilename):
print("WARNING: {}: nothing translatable found in item: {}".format(infilename, item))
Expand Down
2 changes: 2 additions & 0 deletions src/flag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ void json_flag::load( const JsonObject &jo )
jo.read( "conflicts", f.conflicts_ );
jo.read( "inherit", f.inherit_ );
jo.read( "craft_inherit", f.craft_inherit_ );
jo.read( "requires_flag", f.requires_flag_ );
jo.read( "cant_remove", f.cant_remove_ );
jo.read( "taste_mod", f.taste_mod_ );

// FIXME: most flags have a "context" field that isn't used for anything
Expand Down
11 changes: 11 additions & 0 deletions src/flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <set>
#include <string>
#include "translations.h"

class JsonObject;

Expand Down Expand Up @@ -35,6 +36,14 @@ class json_flag
return craft_inherit_;
}

/** Requires this flag to be installed on vehicle */
std::string requires_flag() const {
return requires_flag_;
}
std::string remove_message() const {
return cant_remove_.translated();
}

/** The flag's modifier on the fun value of comestibles */
int taste_mod() const {
return taste_mod_;
Expand All @@ -51,6 +60,8 @@ class json_flag
std::set<std::string> conflicts_;
bool inherit_ = true;
bool craft_inherit_ = false;
std::string requires_flag_;
translation cant_remove_;
int taste_mod_ = 0;

json_flag( const std::string &id = std::string() ) : id_( id ) {}
Expand Down
3 changes: 3 additions & 0 deletions src/veh_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ class vpart_info
// Display order in vehicle interact display
int list_order;

const std::set<std::string> &get_flags() const {
return flags;
}
bool has_flag( const std::string &flag ) const {
return flags.count( flag ) != 0;
}
Expand Down
Loading