Skip to content

Commit

Permalink
Better standardized each editor's load and create logic.
Browse files Browse the repository at this point in the history
- Editors can now show simple text message dialogs.
- If a file or folder fails to load, it now shows a message and returns to the load dialog.
- Made it so dialogs can now use a height of 0 to have it be set automatically to fit the content.
- Better detection for whether something has been loaded, and if something even exists on disk yet.
- Moved some common logic to the parent editor class.
- Toolbars and the main panel now won't show if there's no content loaded. This makes the user's first impression of the editor more soft (so it basically just shows the load dialog), as well as making the new load failed dialog not look confusing with stuff in the background.
  • Loading branch information
Espyo committed Dec 4, 2024
1 parent c6325ed commit 9cc205c
Show file tree
Hide file tree
Showing 20 changed files with 617 additions and 450 deletions.
2 changes: 1 addition & 1 deletion manual/content/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h2 id="0.26.0">0.26.0</h2>
<li><span class="cl-c">Changed</span> the way some things are calculated so the engine runs faster. The most extreme change is that objects that are off-camera and not close to a Pikmin/leader will not be processed.</li>
</ul>

<p><b>Content making changes</b></p>
<p><b>Content-making changes</b></p>

<ul>
<li>
Expand Down
10 changes: 8 additions & 2 deletions source/documents/todo.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Point I left on (so I can continue the next day without losing my train of thought)
Point I left on (so I can continue the next day without losing my train of thought)


Current tasks (tasks being worked on, but not yet committed)
When creating or deleting, update the manifests
If you open a new GUI def file, set the selected GUI item to none
Add editor status bar messages for _creating_ successfully
Are timed levers ticking while off-camera?
In the area editor if you change multiple sectors' heights with H, it should change them all by that amount, if it's not already
When deleting an area, update the manifests
The history should be saved as path;name, so the entry in the history can have a pretty name instead of a cryptic path
A history item should list the item's pack
Find some way of making content sharing easier
Expand Down Expand Up @@ -170,6 +174,7 @@ Next tasks (roughly sorted most important first)
Climbing (add the track logic too)
Sliding (add the track logic too)
Turning (maybe just the walking animation)
Dead (make it different from sleeping, like belly down and with the antenna off) (thanks Helodity, Arcadius)
Misc. graphical improvements
Onions should be shaded with hue shifting
Red Bulborb, Fiery Blowhog, Whiptongue need a depth gradient
Expand Down Expand Up @@ -351,6 +356,7 @@ Next tasks (roughly sorted most important first)
When switching to a leader, all nearby idle Pikmin should be called over too
An option to set how close you need to be to an idle Pikmin to get it into your group: touching, close, or nearby.
Enemy revival
drops_corpse could probably be revamped or removed entirely
A way to start a timer after a random amount of time, based on the coordinates; this allows stuff like a group of fire geysers to start spitting fire at different times
Areas should be able to set their own rules, overwriting config.txt. This should be shown in the area details
Maximum Pikmin in field
Expand Down
24 changes: 17 additions & 7 deletions source/source/content_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,21 @@ bool content_manager::create_pack(
* @brief Loads an area as the "current area". This does not load it into
* the vector of areas.
*
* @param manifest Manifest of the area.
* @param requested_area_path Path to the area folder.
* @param manif_ptr Set the manifest pointer to this. If nullptr, it'll be
* set from the list of manifests.
* @param type Type of area this is.
* @param level Level to load at.
* @param from_backup If true, load from a backup, if any.
* @return Whether it succeeded.
*/
void content_manager::load_area_as_current(
content_manifest* manifest, AREA_TYPE type,
bool content_manager::load_area_as_current(
const string &requested_area_path, content_manifest* manif_ptr,
CONTENT_LOAD_LEVEL level, bool from_backup
) {
engine_assert(
game.cur_area_data == nullptr,
"Tried to load area \"" + manifest->path + "\" as the current "
"Tried to load area \"" + requested_area_path + "\" as the current "
"one even though there is already a loaded current area, \"" +
(
game.cur_area_data->manifest ?
Expand All @@ -191,9 +194,16 @@ void content_manager::load_area_as_current(
);

game.cur_area_data = new area_data();
areas.load_area(
game.cur_area_data, manifest, type, level, from_backup
);
bool success =
areas.load_area(
game.cur_area_data, requested_area_path, manif_ptr,
level, from_backup
);

if(!success) {
unload_current_area(level);
}
return success;
}


Expand Down
4 changes: 2 additions & 2 deletions source/source/content_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ struct content_manager {
const string &internal_name, const string &name,
const string &description = "", const string &maker = ""
);
void load_area_as_current(
content_manifest* manifest, AREA_TYPE type,
bool load_area_as_current(
const string &requested_area_path, content_manifest* manif_ptr,
CONTENT_LOAD_LEVEL level, bool from_backup
);
void load_all(const vector<CONTENT_TYPE> &types, CONTENT_LOAD_LEVEL level);
Expand Down
44 changes: 30 additions & 14 deletions source/source/content_type_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,41 @@ void area_content_manager::load_all(CONTENT_LOAD_LEVEL level) {
* @brief Loads an area.
*
* @param area_ptr Object to load into.
* @param manifest Manifest of the area.
* @param type Type of area this is.
* @param requested_area_path Path to the area's folder.
* @param manif_ptr Set the manifest pointer to this. If nullptr, it'll be
* set from the list of manifests.
* @param level Level to load at.
* @param from_backup If true, load from a backup, if any.
* @return Whether it succeeded.
*/
void area_content_manager::load_area(
area_data* area_ptr, content_manifest* manifest, AREA_TYPE type,
CONTENT_LOAD_LEVEL level, bool from_backup
bool area_content_manager::load_area(
area_data* area_ptr, const string &requested_area_path,
content_manifest* manif_ptr, CONTENT_LOAD_LEVEL level, bool from_backup
) {
//Setup.
content_manifest temp_manif;
AREA_TYPE requested_area_type;
path_to_manifest(requested_area_path, &temp_manif, &requested_area_type);
string user_data_path =
FOLDER_PATHS_FROM_ROOT::AREA_USER_DATA + "/" +
manifest->pack + "/" +
temp_manif.pack + "/" +
(
type == AREA_TYPE_SIMPLE ?
requested_area_type == AREA_TYPE_SIMPLE ?
FOLDER_NAMES::SIMPLE_AREAS :
FOLDER_NAMES::MISSION_AREAS
);
string base_folder_path = from_backup ? user_data_path : manifest->path;
) + "/" +
temp_manif.internal_name;
string base_folder_path = from_backup ? user_data_path : temp_manif.path;

string data_file_path = base_folder_path + "/" + FILE_NAMES::AREA_MAIN_DATA;
data_node data_file = load_data_file(data_file_path);
if(!data_file.file_was_opened) return;
if(!data_file.file_was_opened) return false;

string geometry_file_path = base_folder_path + "/" + FILE_NAMES::AREA_GEOMETRY;
data_node geometry_file = load_data_file(geometry_file_path);
if(!geometry_file.file_was_opened) return;
if(!geometry_file.file_was_opened) return false;

area_ptr->manifest = manifest;
area_ptr->type = type;
area_ptr->type = requested_area_type;
area_ptr->user_data_path = user_data_path;

//Main data.
Expand Down Expand Up @@ -171,6 +176,17 @@ void area_content_manager::load_area(
area_ptr->load_geometry_from_data_node(&geometry_file, level);
if(game.perf_mon) game.perf_mon->finish_measurement();
}

if(manif_ptr) {
area_ptr->manifest = manif_ptr;
} else {
area_ptr->manifest =
find_manifest(
temp_manif.internal_name, temp_manif.pack, requested_area_type
);
}

return true;
}


Expand All @@ -189,7 +205,7 @@ void area_content_manager::load_area_into_vector(
area_data* new_area = new area_data();
list[type].push_back(new_area);
load_area(
new_area, manifest, type,
new_area, manifest->path, manifest,
CONTENT_LOAD_LEVEL_BASIC, from_backup
);
}
Expand Down
5 changes: 3 additions & 2 deletions source/source/content_type_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ class area_content_manager : public content_type_manager {
string get_name() const override;
string get_perf_mon_measurement_name() const override;
void load_all(CONTENT_LOAD_LEVEL level) override;
void load_area(
area_data* area_ptr, content_manifest* manifest, AREA_TYPE type,
bool load_area(
area_data* area_ptr, const string &requested_area_path,
content_manifest* manif_ptr,
CONTENT_LOAD_LEVEL level, bool from_backup
);
string manifest_to_path(
Expand Down
4 changes: 2 additions & 2 deletions source/source/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,15 @@ int game_class::start() {
maker_tools.enabled &&
maker_tools.auto_start_mode == "animation_editor"
) {
states.animation_ed->auto_load_anim =
states.animation_ed->auto_load_file =
maker_tools.auto_start_option;
change_state(states.animation_ed);

} else if(
maker_tools.enabled &&
maker_tools.auto_start_mode == "area_editor"
) {
states.area_ed->auto_load_area =
states.area_ed->auto_load_folder =
maker_tools.auto_start_option;
change_state(states.area_ed);

Expand Down
Loading

0 comments on commit 9cc205c

Please sign in to comment.