Skip to content

Commit

Permalink
Apply settings on game load
Browse files Browse the repository at this point in the history
  • Loading branch information
heimskr committed Mar 10, 2024
1 parent 30f9f77 commit c869911
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/data/Identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace Game3 {
std::string space;
std::string name;

constexpr Identifier() = default;
constexpr Identifier(const char *space_, const char *name_): space(space_), name(name_) {}
Identifier() = default;
Identifier(const char *space_, const char *name_): space(space_), name(name_) {}
Identifier(std::string_view);
Identifier(const char *);

Expand Down
1 change: 1 addition & 0 deletions include/util/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <bit>
#include <cmath>
#include <concepts>
#include <cstdint>
#include <type_traits>

namespace Game3 {
Expand Down
4 changes: 2 additions & 2 deletions src/item/Flower.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "types/Position.h"
#include "graphics/Tileset.h"
#include "entity/Player.h"
#include "game/Game.h"
#include "game/Inventory.h"
#include "graphics/Tileset.h"
#include "item/Flower.h"
#include "realm/Realm.h"
#include "types/Position.h"

namespace Game3 {
Flower::Flower(ItemID identifier_, std::string name_, Identifier tilename_, Identifier valid_ground, MoneyCount base_price, ItemCount max_count):
Expand Down
10 changes: 5 additions & 5 deletions src/item/Pickaxe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace Game3 {
Tool(id_, std::move(name_), base_price, base_cooldown, max_durability, "base:attribute/pickaxe"_id) {}

bool Pickaxe::use(Slot slot, const ItemStackPtr &stack, const Place &place, Modifiers, std::pair<float, float>) {
Realm &realm = *place.realm;
Tileset &tileset = realm.getTileset();
const RealmPtr realm = place.realm;
const Tileset &tileset = realm->getTileset();

if (auto tile = realm.tryTile(Layer::Terrain, place.position); tile && tileset.isInCategory(*tile, "base:category/farmable")) {
if (auto tile = realm->tryTile(Layer::Terrain, place.position); tile && tileset.isInCategory(*tile, "base:category/farmable")) {
{
InventoryPtr inventory = place.player->getInventory(0);
auto lock = inventory->uniqueLock();
Expand All @@ -35,8 +35,8 @@ namespace Game3 {
}

Identifier Pickaxe::findDirtTilename(const Place &place) {
RealmPtr realm = place.realm;
Tileset &tileset = realm->getTileset();
const RealmPtr realm = place.realm;
const Tileset &tileset = realm->getTileset();

for (const Direction direction: ALL_DIRECTIONS)
if (auto tilename = (place + direction).getName(Layer::Terrain); tilename && tileset.isInCategory(*tilename, "base:category/tillable"))
Expand Down
1 change: 1 addition & 0 deletions src/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ namespace Game3 {
debugAction->set_state(Glib::Variant<bool>::create(game->debugMode));
game->initInteractionSets();
canvas->game = game;
settings.apply(*game);

for (auto &[widget, tab]: tabMap)
tab->reset(game);
Expand Down

0 comments on commit c869911

Please sign in to comment.