|
8 | 8 |
|
9 | 9 | #include "activity_actor.h"
|
10 | 10 | #include "activity_handlers.h"
|
11 |
| -#include "assign.h" |
12 | 11 | #include "debug.h"
|
13 | 12 | #include "enums.h"
|
14 |
| -#include "flexbuffer_json.h" |
15 | 13 | #include "generic_factory.h"
|
16 | 14 | #include "sounds.h"
|
17 | 15 | #include "string_formatter.h"
|
@@ -88,30 +86,28 @@ std::string enum_to_string<distraction_type>( distraction_type data )
|
88 | 86 |
|
89 | 87 | void activity_type::load( const JsonObject &jo )
|
90 | 88 | {
|
91 |
| - activity_type result; |
| 89 | + mandatory( jo, was_loaded, "id", id_ ); |
| 90 | + optional( jo, was_loaded, "rooted", rooted_, false ); |
| 91 | + optional( jo, was_loaded, "verb", verb_, to_translation( "THIS IS A BUG" ) ); |
| 92 | + optional( jo, was_loaded, "interruptable", interruptable_, true ); |
| 93 | + optional( jo, was_loaded, "interruptable_with_kb", interruptable_with_kb_, true ); |
| 94 | + optional( jo, was_loaded, "can_resume", can_resume_, true ); |
| 95 | + optional( jo, was_loaded, "multi_activity", multi_activity_, false ); |
| 96 | + optional( jo, was_loaded, "refuel_fires", refuel_fires, false ); |
| 97 | + optional( jo, was_loaded, "auto_needs", auto_needs, false ); |
| 98 | + optional( jo, was_loaded, "completion_eoc", completion_EOC ); |
| 99 | + optional( jo, was_loaded, "do_turn_eoc", do_turn_EOC ); |
| 100 | + optional( jo, was_loaded, "ignored_distractions", default_ignored_distractions_ ); |
| 101 | + optional( jo, was_loaded, "based_on", based_on_ ); |
| 102 | + mandatory( jo, was_loaded, "activity_level", activity_level, activity_level_reader{} ); |
| 103 | +} |
92 | 104 |
|
93 |
| - result.id_ = activity_id( jo.get_string( "id" ) ); |
94 |
| - assign( jo, "rooted", result.rooted_, true ); |
95 |
| - assign( jo, "verb", result.verb_, true ); |
96 |
| - assign( jo, "interruptable", result.interruptable_, true ); |
97 |
| - assign( jo, "interruptable_with_kb", result.interruptable_with_kb_, true ); |
98 |
| - assign( jo, "can_resume", result.can_resume_, true ); |
99 |
| - assign( jo, "multi_activity", result.multi_activity_, false ); |
100 |
| - assign( jo, "refuel_fires", result.refuel_fires, false ); |
101 |
| - assign( jo, "auto_needs", result.auto_needs, false ); |
102 |
| - optional( jo, false, "completion_eoc", result.completion_EOC ); |
103 |
| - optional( jo, false, "do_turn_eoc", result.do_turn_EOC ); |
104 |
| - optional( jo, false, "ignored_distractions", result.default_ignored_distractions_ ); |
105 |
| - optional( jo, false, "based_on", result.based_on_ ); |
106 |
| - |
107 |
| - auto act_level_it = activity_levels_map.find( jo.get_string( "activity_level", "undefined" ) ); |
108 |
| - if( act_level_it == activity_levels_map.end() ) { |
109 |
| - debugmsg( "activity_type '%s' has invalid activity_level '%s', defaulting to 'LIGHT_EXERCISE'", |
110 |
| - result.id().c_str() ); |
111 |
| - result.activity_level = activity_levels_map.at( "LIGHT_EXERCISE" ); |
112 |
| - } else { |
113 |
| - result.activity_level = act_level_it->second; |
114 |
| - } |
| 105 | +void activity_type::load_all( const JsonObject &jo ) |
| 106 | +{ |
| 107 | + activity_type result; |
| 108 | + result.load( jo ); |
| 109 | + // FIXME: use generic factory |
| 110 | + result.was_loaded = true; |
115 | 111 |
|
116 | 112 | if( activity_type_all.count( result.id_ ) ) {
|
117 | 113 | debugmsg( "Redefinition of %s", result.id_.c_str() );
|
|
0 commit comments