diff --git a/assets/config.json b/assets/config.json index 30e1539..901a86f 100644 --- a/assets/config.json +++ b/assets/config.json @@ -16,6 +16,11 @@ "frame_width": 1024, "frame_height": 1024 }, + "work_computer": + {"path": "assets/work_computer-1024.png", + "frame_width": 1024, + "frame_height": 1024 + }, "clicker_treat_bone": {"path": "assets/clicker_treat_bone.png", "frame_width": 256, diff --git a/assets/work_computer-1024.png b/assets/work_computer-1024.png new file mode 100644 index 0000000..295b8ee Binary files /dev/null and b/assets/work_computer-1024.png differ diff --git a/main.cpp b/main.cpp index b7d7c56..0b3c7e5 100644 --- a/main.cpp +++ b/main.cpp @@ -5,10 +5,11 @@ #include #include -constexpr const int WINDOW_WIDTH=1280; -constexpr const int WINDOW_HEIGHT=720; +constexpr const int SCREEN_WIDTH=1280; +constexpr const int SCREEN_HEIGHT=720; constexpr const int FRAME_LIMIT=60; constexpr const bool VSYNC=true; +bool GO_TO_WORK = false; using std::string, std::wstring; @@ -71,13 +72,13 @@ struct ClickerUI { guecs::Entity $clicker; ClickerUI() { - $gui.position(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); + $gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); $gui.layout( - "[_|*%(300,400)clicker|_|_|_]" - "[_|_ |_|_|_]" - "[_|_ |_|_|_]" - "[_|_ |_|_|_]" - "[a1|a2|a3|a4|a5]"); + "[FoodBowl|_|*%(300,400)clicker|_|_|_]" + "[WaterBowl|_|_ |_|_|_]" + "[Mood|_|_ |_|_|_]" + "[_|_|_ |_|_|_]" + "[Treat|Food|Water|Pet|Work]"); } void init() { @@ -88,11 +89,18 @@ struct ClickerUI { if(name != "clicker") { $gui.set(id, {}); $gui.set(id, {}); - $gui.set(id, { "clicker_treat_bone" }); - fmt::println("button dim: {},{}", cell.w, cell.h); - $gui.set(id, { - [&](auto, auto) { handle_button(Event::A_BUTTON); } - }); + $gui.set(id, { guecs::to_wstring(name) }); + + if(name == "Work") { + $gui.set(id, { [&](auto, auto) { + GO_TO_WORK = true; + fmt::println("Going to Work!"); + } }); + } else { + $gui.set(id, { + [&](auto, auto) { handle_button(Event::A_BUTTON); } + }); + } } } @@ -146,17 +154,51 @@ struct ClickerUI { } }; + +struct WorkComputerUI { + guecs::UI $gui; + + WorkComputerUI() { + $gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + $gui.layout("[_|*%(300)computer|_|_|_]"); + } + + void init() { + auto computer = $gui.entity("computer"); + $gui.set(computer, {"work_computer"}); + $gui.set(computer, {L"Work Computer"}); + $gui.set(computer, { [&](auto, auto) { + GO_TO_WORK = false; + fmt::println("Leaving Work!"); + } }); + + $gui.init(); + } + + void render(sf::RenderWindow& window) { + $gui.render(window); + } + + void mouse(float x, float y, bool hover) { + $gui.mouse(x, y, hover); + } +}; + + int main() { sfml::Backend backend; guecs::init(&backend); - sf::RenderWindow window(sf::VideoMode({WINDOW_WIDTH, WINDOW_HEIGHT}), "Clicker the Dog"); + sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Clicker the Dog"); window.setFramerateLimit(FRAME_LIMIT); window.setVerticalSyncEnabled(VSYNC); ClickerUI clicker; clicker.init(); + WorkComputerUI computer; + computer.init(); + while(window.isOpen()) { while (const auto event = window.pollEvent()) { if(event->is()) { @@ -166,12 +208,21 @@ int main() { if(const auto* mouse = event->getIf()) { if(mouse->button == sf::Mouse::Button::Left) { sf::Vector2f pos = window.mapPixelToCoords(mouse->position); - clicker.mouse(pos.x, pos.y, false); + if(GO_TO_WORK) { + computer.mouse(pos.x, pos.y, false); + } else { + clicker.mouse(pos.x, pos.y, false); + } } } } - clicker.render(window); + if(GO_TO_WORK) { + window.clear(); + computer.render(window); + } else { + clicker.render(window); + } window.display(); } }