diff --git a/PLAN.md b/PLAN.md index edaef1d..8b82688 100644 --- a/PLAN.md +++ b/PLAN.md @@ -2,7 +2,7 @@ ## Цель -Самостоятельная C++-игра о поселении с повторяемой симуляцией, многопоточным расчётом и изометрическим клиентом. Это отдельный проект, не совместимый движок для Stonehearth. Код и игровые ресурсы Stonehearth не включаются. +Самостоятельная C++-игра о поселении с повторяемой симуляцией, многопоточным расчётом и 3D-клиентом. Это отдельный проект, не совместимый движок для Stonehearth. Код и игровые ресурсы Stonehearth не включаются. ## Этапы @@ -44,12 +44,12 @@ ### P4 — Игровой клиент -- [x] Изометрический Windows-просмотрщик карты, маршрутов и жителей. +- [x] Windows-клиент с отображением карты, маршрутов и жителей. - [x] Отображение источников ресурсов, складов и текущих запасов. - [x] Камера с перемещением и масштабированием относительно курсора. - [x] Нижняя панель с жителями, добычей, участками и строительством. -- [x] Главное меню перед игрой со списком сохранений, продолжением партии и подключением к другу. -- [x] Меню Esc с паузой, сохранениями, графикой и сетевыми действиями. +- [x] Главное меню со списком сохранений, продолжением партии и управлением кооперативом. +- [x] Меню Esc с паузой, сохранениями, выходом в главное меню и завершением игры. - [x] Игровая карта на Direct3D 11 с глубиной и базовыми объёмными моделями. - [ ] Расширение набора 3D-моделей и освещения. - [x] Постановка чертежа домика мышью в Windows-клиенте. diff --git a/app/isometric_camera.hpp b/app/map_camera.hpp similarity index 97% rename from app/isometric_camera.hpp rename to app/map_camera.hpp index 0bdf4ba..e885ec2 100644 --- a/app/isometric_camera.hpp +++ b/app/map_camera.hpp @@ -10,7 +10,7 @@ struct ScreenPoint { double y; }; -class IsometricCamera { +class MapCamera { public: [[nodiscard]] double scale() const noexcept { return scale_; } [[nodiscard]] ScreenPoint offset() const noexcept { return offset_; } diff --git a/app/title_screen_win32.hpp b/app/title_screen_win32.hpp index e00f37f..9710681 100644 --- a/app/title_screen_win32.hpp +++ b/app/title_screen_win32.hpp @@ -15,7 +15,7 @@ namespace settlement::viewer { constexpr int title_continue_id = 1100; constexpr int title_new_id = 1101; constexpr int title_browse_id = 1102; -constexpr int title_join_id = 1103; +constexpr int title_coop_id = 1103; constexpr int title_exit_id = 1104; constexpr int title_saves_id = 1105; constexpr int title_open_id = 1106; @@ -39,7 +39,7 @@ public: void create(HWND owner) { constexpr const wchar_t* names[] = { - L"Продолжить", L"Новая колония", L"Открыть файл…", L"Подключиться к другу…", L"Выход" + L"Продолжить", L"Новая колония", L"Открыть файл…", L"Кооператив…", L"Выход" }; const auto instance = GetModuleHandleW(nullptr); for (std::size_t i = 0; i < buttons_.size(); ++i) { @@ -92,11 +92,12 @@ public: ShowWindow(open_, flags); } - void update(bool has_session, bool connecting) const { - EnableWindow(buttons_[0], !connecting && (has_session || !saves.empty())); - for (std::size_t i = 1; i < buttons_.size() - 1; ++i) EnableWindow(buttons_[i], !connecting); - EnableWindow(open_, !connecting && selected_index() < saves.size()); - EnableWindow(saves_, !connecting); + void update(bool can_resume, bool offline) const { + EnableWindow(buttons_[0], can_resume || (offline && !saves.empty())); + EnableWindow(buttons_[title_new_id - title_continue_id], offline); + EnableWindow(buttons_[title_browse_id - title_continue_id], offline); + EnableWindow(open_, offline && selected_index() < saves.size()); + EnableWindow(saves_, offline); } HBRUSH paint_list_background(HWND control, HDC dc) const { @@ -126,7 +127,6 @@ public: void draw(HDC dc, int width, int height, const std::wstring& notice) const { shade(dc, {0, 0, width, height}, RGB(24, 38, 34)); - // A simple isometric landscape with the same palette as the colony map. const auto old_pen = SelectObject(dc, GetStockObject(NULL_PEN)); const auto distant = CreateSolidBrush(RGB(32, 53, 44)); const auto near_hills = CreateSolidBrush(RGB(41, 66, 50)); diff --git a/app/viewer_win32.cpp b/app/viewer_win32.cpp index fa1f2f5..538b1f2 100644 --- a/app/viewer_win32.cpp +++ b/app/viewer_win32.cpp @@ -7,7 +7,7 @@ #include #include "d3d_scene_win32.hpp" -#include "isometric_camera.hpp" +#include "map_camera.hpp" #include "lan_session.hpp" #include "title_screen_win32.hpp" #include "settlement/core/world.hpp" @@ -33,7 +33,7 @@ namespace { -constexpr wchar_t window_class[] = L"SettlementIsometricViewer"; +constexpr wchar_t window_class[] = L"SettlementViewer"; constexpr wchar_t resident_window_class[] = L"SettlementResidentRoster"; constexpr wchar_t scene_window_class[] = L"SettlementD3DViewport"; constexpr int title_menu_id = 1002; @@ -69,7 +69,6 @@ constexpr int resident_list_id = 1060; constexpr int first_role_id = 1070; constexpr int first_dock_section_id = 1080; constexpr int work_list_button_id = 1083; -constexpr int graphics_menu_id = 1120; constexpr int exit_menu_id = 1121; constexpr int timer_id = 1; constexpr int map_size = settlement::first_colony_map_size; @@ -100,10 +99,11 @@ namespace title = settlement::viewer; title::TitleScreen title_screen; bool showing_title = true; bool has_session = false; +bool enter_game_on_snapshot = false; +bool coop_menu_open = false; bool pause_menu_open = false; HWND scene_window = nullptr; settlement::viewer::D3DScene graphics; -bool prefer_direct3d = true; using settlement::viewer::LanState; settlement::viewer::LanSession lan; LanState displayed_lan_state = LanState::Offline; @@ -187,7 +187,7 @@ struct ResidentRoster { ResidentRoster roster; std::optional selected_bed_base; std::optional move_source; -settlement::viewer::IsometricCamera camera; +settlement::viewer::MapCamera camera; struct CameraDrag { POINT previous; bool left_button; @@ -318,7 +318,7 @@ void draw_work_icon(HDC dc, WorkIcon icon, int x, int y) { RestoreDC(dc, state); } -POINT iso_point(int x, int y, int origin_x, int origin_y) { +POINT map_projection(int x, int y, int origin_x, int origin_y) { return POINT{origin_x + (x - y) * tile_width / 2, origin_y + (x + y) * tile_height / 2}; } @@ -328,7 +328,7 @@ bool shows_bed_choices() { } bool is_map_point(const RECT& client, POINT point) { - return !showing_title && point.x >= 0 && point.x < client.right && + return !showing_title && graphics.ready() && point.x >= 0 && point.x < client.right && point.y >= map_top && point.y < client.bottom - map_footer; } @@ -341,14 +341,14 @@ void invalidate_scene(HWND window) { GetClientRect(window, &scene); scene.top = map_top; if (scene.bottom > scene.top) InvalidateRect(window, &scene, FALSE); - if (!showing_title && prefer_direct3d && graphics.ready() && scene_window) { + if (!showing_title && graphics.ready() && scene_window) { InvalidateRect(scene_window, nullptr, FALSE); } } void layout_scene(HWND window) { if (!scene_window) return; - if (showing_title || !prefer_direct3d || !graphics.ready()) { + if (showing_title || !graphics.ready()) { ShowWindow(scene_window, SW_HIDE); return; } @@ -392,174 +392,6 @@ void update_map_hover(HWND window, POINT point) { invalidate_scene(window); } -void draw_ground_tile(HDC dc, POINT center, COLORREF fill, COLORREF outline) { - const POINT diamond[] = { - {center.x, center.y - tile_height / 2}, - {center.x + tile_width / 2, center.y}, - {center.x, center.y + tile_height / 2}, - {center.x - tile_width / 2, center.y} - }; - fill_polygon(dc, diamond, 4, fill, outline); -} - -void draw_rock(HDC dc, POINT ground_center) { - constexpr int block_height = 17; - const int x = ground_center.x; - const int y = ground_center.y; - const POINT left_face[] = { - {x - tile_width / 2, y}, {x, y + tile_height / 2}, - {x, y + tile_height / 2 - block_height}, {x - tile_width / 2, y - block_height} - }; - const POINT right_face[] = { - {x, y + tile_height / 2}, {x + tile_width / 2, y}, - {x + tile_width / 2, y - block_height}, {x, y + tile_height / 2 - block_height} - }; - const POINT top_face[] = { - {x, y - tile_height / 2 - block_height}, - {x + tile_width / 2, y - block_height}, - {x, y + tile_height / 2 - block_height}, - {x - tile_width / 2, y - block_height} - }; - fill_polygon(dc, left_face, 4, color(91, 109, 103), color(70, 87, 81)); - fill_polygon(dc, right_face, 4, color(67, 84, 79), color(60, 76, 71)); - fill_polygon(dc, top_face, 4, color(132, 148, 132), color(76, 94, 83)); -} - -void draw_resource(HDC dc, POINT center, settlement::ItemType type) { - if (type == settlement::ItemType::Berries) { - fill_ellipse(dc, center.x - 7, center.y - 7, center.x + 7, center.y + 3, - color(77, 135, 67), color(51, 98, 57)); - for (const POINT berry : {POINT{-3, -4}, POINT{1, -1}, POINT{3, -5}}) { - fill_ellipse(dc, center.x + berry.x - 1, center.y + berry.y - 1, - center.x + berry.x + 2, center.y + berry.y + 2, - color(190, 76, 112), color(115, 48, 76)); - } - } else if (type == settlement::ItemType::Flax) { - for (const POINT stalk : {POINT{-5, -4}, POINT{0, -10}, POINT{5, -6}}) { - const LONG x = center.x + stalk.x; - const LONG y = center.y + stalk.y; - const POINT stem[] = {{x - 1, y}, {x + 1, y}, {x + 2, y + 8}, {x, y + 8}}; - fill_polygon(dc, stem, 4, color(114, 160, 79), color(64, 106, 65)); - fill_ellipse(dc, x - 2, y - 3, x + 3, y + 2, color(117, 160, 234), color(61, 86, 156)); - } - } else if (type == settlement::ItemType::Wood) { - HPEN trunk = CreatePen(PS_SOLID, 2, color(104, 83, 54)); - HGDIOBJ old_pen = SelectObject(dc, trunk); - MoveToEx(dc, center.x, center.y + 3, nullptr); - LineTo(dc, center.x, center.y - 8); - SelectObject(dc, old_pen); - DeleteObject(trunk); - fill_ellipse(dc, center.x - 7, center.y - 13, center.x + 1, center.y - 5, - color(71, 128, 69), color(62, 104, 61)); - fill_ellipse(dc, center.x - 1, center.y - 17, center.x + 7, center.y - 9, - color(92, 148, 77), color(62, 104, 61)); - } else { - const POINT rock[] = { - {center.x - 7, center.y + 2}, {center.x - 5, center.y - 5}, - {center.x + 2, center.y - 8}, {center.x + 7, center.y - 2}, - {center.x + 6, center.y + 3} - }; - fill_polygon(dc, rock, 5, color(133, 143, 143), color(86, 100, 101)); - } -} - -void draw_site(HDC dc, POINT center, const settlement::ResourceNode& node) { - using settlement::ResourceSite; - if (node.site == ResourceSite::Mine) { - const int x = center.x; - const int y = center.y; - const POINT pit[] = {{x - 10, y - 1}, {x, y + 5}, {x + 10, y - 1}, {x, y - 7}}; - const POINT beam[] = {{x - 7, y - 2}, {x - 6, y - 10}, {x + 5, y - 10}, {x + 6, y - 2}}; - fill_polygon(dc, beam, 4, color(124, 104, 78), color(66, 62, 53)); - fill_polygon(dc, pit, 4, node.quantity != 0 ? color(68, 75, 79) : color(122, 122, 113), - color(55, 63, 65)); - return; - } - if (node.site != ResourceSite::Natural) { - draw_ground_tile(dc, center, color(161, 125, 80), color(107, 95, 64)); - if (node.quantity == 0) { - if (!node.needs_tending()) { - fill_ellipse(dc, center.x - 4, center.y - 3, center.x + 3, center.y + 1, - color(91, 139, 80), color(64, 91, 62)); - } else if (node.reserved_workers > 0) { - fill_ellipse(dc, center.x - 3, center.y - 2, center.x + 3, center.y + 2, - color(225, 192, 117), color(122, 99, 56)); - } - return; - } - } - draw_resource(dc, center, node.type); -} - -void draw_storage(HDC dc, POINT center, settlement::StorageKind kind) { - const POINT front[] = {{center.x - 7, center.y - 1}, {center.x, center.y + 3}, - {center.x, center.y - 6}, {center.x - 7, center.y - 10}}; - const POINT side[] = {{center.x, center.y + 3}, {center.x + 7, center.y - 1}, - {center.x + 7, center.y - 10}, {center.x, center.y - 6}}; - const POINT lid[] = {{center.x - 7, center.y - 10}, {center.x, center.y - 14}, - {center.x + 7, center.y - 10}, {center.x, center.y - 6}}; - fill_polygon(dc, front, 4, color(165, 111, 59), color(93, 66, 42)); - fill_polygon(dc, side, 4, color(128, 82, 45), color(93, 66, 42)); - const COLORREF lid_color = kind == settlement::StorageKind::Pantry ? color(176, 89, 125) : color(193, 143, 84); - fill_polygon(dc, lid, 4, lid_color, color(93, 66, 42)); -} - -void draw_production(HDC dc, POINT center, const settlement::ProductionOrder& order) { - using settlement::JobState; - using settlement::RecipeId; - if (order.recipe == RecipeId::WeaveCloth) { - const auto [x, y] = center; - const POINT frame[] = {{x - 8, y + 3}, {x - 8, y - 14}, {x + 8, y - 10}, {x + 8, y + 6}}; - const POINT fabric[] = {{x - 5, y - 11}, {x + 5, y - 8}, {x + 5, y + 1}, {x - 5, y - 2}}; - fill_polygon(dc, frame, 4, color(176, 124, 74), color(91, 63, 45)); - fill_polygon(dc, fabric, 4, order.state == JobState::InProgress ? color(250, 230, 170) : - color(227, 216, 194), color(127, 112, 85)); - return; - } - if (!settlement::is_construction(order.recipe)) { - const POINT bench[] = {{center.x - 8, center.y - 4}, {center.x, center.y}, - {center.x + 8, center.y - 4}, {center.x, center.y - 8}}; - const COLORREF fill = order.recipe == RecipeId::SawPlank ? color(180, 118, 69) : color(131, 145, 151); - fill_polygon(dc, bench, 4, fill, color(65, 62, 50)); - return; - } - - if (order.state != JobState::Completed) { - const COLORREF fill = order.state == JobState::Available ? color(145, 191, 205) : - order.delivery_stops.empty() ? color(223, 165, 72) : color(83, 162, 150); - draw_ground_tile(dc, center, fill, color(74, 111, 126)); - if (order.recipe != RecipeId::BuildBed || order.bed_stage == settlement::BedStage::Legacy || - order.bed_stage == settlement::BedStage::Foundation) return; - } - - const int x = center.x; - const int y = center.y; - if (order.recipe == RecipeId::BuildBed) { - const POINT frame[] = {{x - 10, y - 4}, {x, y + 2}, {x + 10, y - 4}, {x, y - 10}}; - const POINT mattress[] = {{x - 8, y - 6}, {x, y - 1}, {x + 8, y - 6}, {x, y - 11}}; - const POINT pillow[] = {{x - 6, y - 6}, {x - 3, y - 4}, {x + 1, y - 6}, {x - 2, y - 8}}; - const auto frame_color = order.bed_base == settlement::BedBase::Stone - ? color(148, 153, 156) : color(156, 103, 63); - fill_polygon(dc, frame, 4, frame_color, color(87, 61, 44)); - if (order.state == JobState::Completed || order.bed_stage == settlement::BedStage::Pillow) { - fill_polygon(dc, mattress, 4, color(116, 146, 186), color(67, 85, 111)); - } - if (order.state == JobState::Completed) { - fill_polygon(dc, pillow, 4, color(244, 234, 206), color(143, 132, 113)); - } - return; - } - const COLORREF outline = color(89, 60, 47); - const POINT front[] = {{x - 11, y - 10}, {x, y - 4}, {x, y + 6}, {x - 11, y}}; - const POINT side[] = {{x, y - 4}, {x + 11, y - 10}, {x + 11, y}, {x, y + 6}}; - const POINT roof_left[] = {{x - 12, y - 10}, {x - 5, y - 20}, {x + 6, y - 14}, {x, y - 4}}; - const POINT roof_right[] = {{x + 6, y - 14}, {x + 12, y - 10}, {x, y - 4}}; - fill_polygon(dc, front, 4, color(210, 158, 98), outline); - fill_polygon(dc, side, 4, color(172, 125, 74), outline); - fill_polygon(dc, roof_left, 4, color(173, 83, 62), outline); - fill_polygon(dc, roof_right, 3, color(135, 63, 53), outline); -} - POINT resident_position(POINT center, settlement::AgentId id) { const int offset = static_cast(id % 5) - 2; return {center.x + offset * 2, center.y - 4}; @@ -577,42 +409,6 @@ POINT resident_anchor(POINT center, const settlement::Agent& agent) { return resident_position(center, agent.id); } -void draw_resident(HDC dc, POINT center, const settlement::Agent& agent) { - using settlement::AgentState; - using settlement::ItemType; - COLORREF body = color(51, 145, 137); - switch (agent.state) { - case AgentState::Idle: body = color(56, 111, 174); break; - case AgentState::Travelling: - case AgentState::FetchingMaterials: body = color(125, 81, 181); break; - case AgentState::Working: body = color(199, 88, 65); break; - case AgentState::Gathering: body = color(193, 143, 64); break; - case AgentState::GoingToEat: - case AgentState::Eating: body = color(189, 89, 134); break; - case AgentState::GoingToSleep: - case AgentState::Sleeping: body = color(78, 99, 147); break; - case AgentState::Hauling: break; - } - const auto [x, y] = resident_anchor(center, agent); - const COLORREF ground = selected_resident == agent.id ? color(248, 218, 107) : color(116, 108, 90); - fill_ellipse(dc, x - 6, y + 7, x + 6, y + 11, ground, color(116, 108, 90)); - if (agent.state == AgentState::Sleeping) { - fill_ellipse(dc, x - 7, y + 1, x + 6, y + 8, body, color(55, 66, 98)); - fill_ellipse(dc, x + 3, y, x + 8, y + 6, color(232, 194, 143), color(113, 88, 64)); - return; - } - fill_ellipse(dc, x - 4, y, x + 4, y + 8, body, color(255, 255, 255)); - fill_ellipse(dc, x - 3, y - 5, x + 3, y + 1, color(232, 194, 143), color(113, 88, 64)); - if (!agent.inventory.empty()) { - const POINT pack[] = {{x + 2, y + 2}, {x + 8, y + 2}, {x + 8, y + 8}, {x + 2, y + 8}}; - COLORREF cargo = color(229, 186, 112); - if (agent.inventory.item_count(ItemType::Berries) > 0) cargo = color(211, 108, 149); - if (agent.inventory.item_count(ItemType::Flax) > 0) cargo = color(135, 172, 235); - if (agent.inventory.item_count(ItemType::Cloth) > 0) cargo = color(244, 232, 204); - fill_polygon(dc, pack, 4, cargo, color(97, 73, 48)); - } -} - const wchar_t* profession_name(settlement::Profession profession) { const auto choice = std::find_if(role_choices.begin(), role_choices.end(), [profession](const auto& entry) { return entry.role == profession; }); @@ -937,6 +733,14 @@ void toggle_work_panel(HWND window, WorkPanel panel) { SetFocus(window); } +bool can_resume_session() { + return has_session && lan.state() != LanState::Connecting && lan.state() != LanState::GuestDisconnected; +} + +void update_title_controls() { + title_screen.update(can_resume_session(), lan.state() == LanState::Offline); +} + void show_title_screen(HWND window, bool visible) { showing_title = visible; if (visible) { @@ -944,11 +748,12 @@ void show_title_screen(HWND window, bool visible) { set_work_panel(window, WorkPanel::None); set_placement_mode(window, PlacementMode::None); title_screen.reload_saves(); - title_screen.update(has_session, lan.state() == LanState::Connecting); + update_title_controls(); } else { has_session = true; - if (prefer_direct3d && !graphics.ready() && (!scene_window || !graphics.initialize(scene_window))) { - prefer_direct3d = false; + enter_game_on_snapshot = false; + if (!graphics.ready() && scene_window && !graphics.initialize(scene_window)) { + graphics.initialize(scene_window, true); } } const int flags = visible ? SW_HIDE : SW_SHOWNA; @@ -1159,7 +964,7 @@ void show_lan_info(HWND window) { (addresses.empty() ? std::wstring(L"см. ipconfig") : widen_ascii(addresses)) + L"\nКод партии: " + widen_ascii(lan.join_code()) + L"\nПорт TCP: " + std::to_wstring(lan.port()) + - L"\n\nДруг в той же сети выбирает «Подключиться к другу…» в главном меню."; + L"\n\nДруг в той же сети выбирает «Кооператив → Подключиться к другу…» в главном меню."; MessageBoxW(window, text.c_str(), L"Кооператив по локальной сети", MB_OK | MB_ICONINFORMATION); } @@ -1180,35 +985,45 @@ void refresh_lan_controls(HWND window) { SetWindowTextW(window, caption.c_str()); if (disconnected) { set_placement_mode(window, PlacementMode::None); - placement_message = showing_title ? L"Не удалось подключиться. Проверьте адрес и код." : - L"Связь прервана. «Esc → Подключиться снова». " + widen_ascii(lan.detail()); + enter_game_on_snapshot = false; + placement_message = showing_title ? L"Связь потеряна. Откройте «Кооператив», чтобы подключиться снова." : + L"Связь прервана. Переподключение — в разделе «Кооператив» главного меню."; } else if (state == LanState::GuestConnected) { placement_message = L"Подключено к колонии хозяина."; } if (roster.window) update_roster_details(); update_status(); if (showing_title) { - title_screen.update(has_session, state == LanState::Connecting); + update_title_controls(); InvalidateRect(window, nullptr, FALSE); } invalidate_scene(window); } void handle_lan_menu(HWND window, int command) { + if (!showing_title) return; try { if (command == lan_host_id && lan.state() == LanState::Offline) { - if (!world || !world->scenario_active()) { - throw std::runtime_error("Start the playable colony before hosting."); - } + auto colony = !has_session || !world || !world->scenario_active() + ? settlement::make_first_colony(local_worker_count) : nullptr; lan.host(); + if (colony) { + world = std::move(colony); + camera = {}; + selected_resident.reset(); + } + has_session = true; + placement_message = L"Сетевая колония открыта. Нажмите «Продолжить», чтобы войти."; refresh_lan_controls(window); show_lan_info(window); + return; } else if (command == lan_join_id && (lan.state() == LanState::Offline || lan.state() == LanState::GuestDisconnected)) { const auto request = ask_join_address(window); if (!request) return; if (!world) world = settlement::make_first_colony(local_worker_count); lan.join(narrow_lan_input(request->address.data()), narrow_lan_input(request->code.data())); + enter_game_on_snapshot = true; selected_resident.reset(); sync_resident_roster(true); set_work_panel(window, WorkPanel::None); @@ -1216,10 +1031,13 @@ void handle_lan_menu(HWND window, int command) { } else if (command == lan_info_id && !lan.is_guest() && lan.state() != LanState::Offline) { show_lan_info(window); return; - } else if (command == lan_reconnect_id) { + } else if (command == lan_reconnect_id && lan.state() == LanState::GuestDisconnected) { lan.reconnect(); + enter_game_on_snapshot = true; + placement_message = L"Подключаемся к хозяину…"; } else if (command == lan_leave_id) { lan.leave(); + enter_game_on_snapshot = false; set_work_panel(window, WorkPanel::None); set_placement_mode(window, PlacementMode::None, L"Сетевая игра завершена."); } @@ -1230,18 +1048,26 @@ void handle_lan_menu(HWND window, int command) { } } +void open_coop_menu(HWND window); + void handle_title_command(HWND window, int command, int notification) { if (command == title::title_exit_id && notification == BN_CLICKED) { DestroyWindow(window); return; } - if (lan.state() == LanState::Connecting) return; - if (command == title::title_saves_id && notification == LBN_SELCHANGE) { - title_screen.update(has_session, false); + if (command == title::title_coop_id && notification == BN_CLICKED) { + open_coop_menu(window); return; } - if (command == title::title_join_id && notification == BN_CLICKED) { - handle_lan_menu(window, lan_join_id); + const bool offline = lan.state() == LanState::Offline; + if (command == title::title_continue_id && notification == BN_CLICKED && can_resume_session()) { + show_title_screen(window, false); + refresh_lan_controls(window); + return; + } + if (!offline) return; + if (command == title::title_saves_id && notification == LBN_SELCHANGE) { + update_title_controls(); return; } const bool open_selected = (command == title::title_open_id && notification == BN_CLICKED) || @@ -1250,15 +1076,12 @@ void handle_title_command(HWND window, int command, int notification) { (command != title::title_new_id && command != title::title_continue_id && command != title::title_browse_id))) { return; } - if (lan.state() == LanState::GuestDisconnected) lan.leave(); if (open_selected) { if (const auto path = title_screen.selected_save()) handle_save_menu(window, false, path); } else if (command == title::title_new_id) { reset_world(window); } else if (command == title::title_browse_id) { handle_save_menu(window, false); - } else if (has_session) { - show_title_screen(window, false); } else if (const auto path = title_screen.latest_save()) { handle_save_menu(window, false, path); } @@ -1559,7 +1382,7 @@ std::optional resident_at(HWND window, POINT point) { double closest = 65.0; for (const auto& agent : world->agents()) { const auto position = resident_anchor( - iso_point(agent.position.x, agent.position.y, client.right / 2, map_origin_y), agent); + map_projection(agent.position.x, agent.position.y, client.right / 2, map_origin_y), agent); const double dx = scene.x - position.x; const double dy = scene.y - (position.y + 2); if (std::abs(dx) > 8 || std::abs(dy) > 8) continue; @@ -1623,104 +1446,6 @@ std::wstring resident_details() { return text; } -void draw_map(HDC dc, int width) { - const int origin_x = width / 2; - const int origin_y = map_origin_y; - for (int y = 0; y < map_size; ++y) { - for (int x = 0; x < map_size; ++x) { - const POINT center = iso_point(x, y, origin_x, origin_y); - const bool walkable = world->is_walkable({x, y}); - const COLORREF grass = ((x * 7 + y * 11) % 9 == 0) ? color(158, 183, 124) : color(171, 195, 135); - draw_ground_tile(dc, center, walkable ? grass : color(118, 133, 118), color(149, 170, 130)); - if (hover_cell && *hover_cell == settlement::GridPosition{x, y} && - (!shows_bed_choices() || selected_bed_base.has_value())) { - const bool valid = valid_edit_cell(*hover_cell); - draw_ground_tile(dc, center, valid ? color(154, 207, 225) : color(216, 140, 126), - valid ? color(53, 116, 141) : color(147, 70, 58)); - } - if (move_source == settlement::GridPosition{x, y}) { - draw_ground_tile(dc, center, color(224, 197, 125), color(124, 98, 47)); - } - } - } - - const HPEN trail_pen = CreatePen(PS_SOLID, 1, color(100, 82, 134)); - const HPEN delivery_pen = CreatePen(PS_SOLID, 2, color(38, 122, 112)); - const HPEN meal_pen = CreatePen(PS_SOLID, 2, color(168, 67, 109)); - const HPEN sleep_pen = CreatePen(PS_SOLID, 2, color(76, 98, 142)); - const HGDIOBJ original_pen = SelectObject(dc, trail_pen); - for (const auto& agent : world->agents()) { - using settlement::AgentState; - if (agent.state != AgentState::Travelling && agent.state != AgentState::Hauling && - agent.state != AgentState::FetchingMaterials && agent.state != AgentState::GoingToEat && - agent.state != AgentState::GoingToSleep) continue; - HPEN pen = trail_pen; - if (agent.state == AgentState::GoingToEat) pen = meal_pen; - else if (agent.state == AgentState::GoingToSleep) pen = sleep_pen; - else if (agent.production_index != settlement::no_entity_index && agent.state == AgentState::Hauling) { - pen = delivery_pen; - } - SelectObject(dc, pen); - const POINT start = iso_point(agent.position.x, agent.position.y, origin_x, origin_y); - MoveToEx(dc, start.x, start.y, nullptr); - for (std::size_t i = agent.route_cursor; i < agent.route.size(); ++i) { - const POINT point = iso_point(agent.route[i].x, agent.route[i].y, origin_x, origin_y); - LineTo(dc, point.x, point.y); - } - } - SelectObject(dc, original_pen); - DeleteObject(trail_pen); - DeleteObject(delivery_pen); - DeleteObject(meal_pen); - DeleteObject(sleep_pen); - - for (int depth = 0; depth <= (map_size - 1) * 2; ++depth) { - const int min_x = std::max(0, depth - (map_size - 1)); - const int max_x = std::min(map_size - 1, depth); - for (int x = min_x; x <= max_x; ++x) { - const int y = depth - x; - const POINT center = iso_point(x, y, origin_x, origin_y); - if (!world->is_walkable({x, y})) draw_rock(dc, center); - - for (const settlement::ResourceNode& node : world->resource_nodes()) { - if (node.position.x == x && node.position.y == y && - (node.quantity > 0 || node.type == settlement::ItemType::Berries || - node.site != settlement::ResourceSite::Natural)) { - if (node.type == settlement::ItemType::Berries && node.foraging_enabled) { - draw_ground_tile(dc, center, color(169, 202, 120), color(57, 112, 65)); - } - draw_site(dc, center, node); - } - } - for (const settlement::Storage& storage : world->storages()) { - if (storage.position.x == x && storage.position.y == y) draw_storage(dc, center, storage.kind); - } - for (const settlement::ProductionOrder& order : world->production_orders()) { - if (order.position.x != x || order.position.y != y) continue; - draw_production(dc, center, order); - break; - } - - for (const settlement::WorkJob& job : world->jobs()) { - if (job.position.x != x || job.position.y != y) continue; - const COLORREF job_color = job.state == settlement::JobState::Available ? color(66, 143, 85) : - job.state == settlement::JobState::InProgress ? color(220, 151, 53) : color(148, 151, 145); - const POINT marker[] = { - {center.x, center.y - 4}, {center.x + 4, center.y - 2}, - {center.x, center.y}, {center.x - 4, center.y - 2} - }; - fill_polygon(dc, marker, 4, job_color, color(75, 83, 69)); - } - - for (const settlement::Agent& agent : world->agents()) { - if (agent.position.x != x || agent.position.y != y) continue; - draw_resident(dc, center, agent); - } - } - } - -} - void draw_world(HDC dc, int width, int height) { RECT bounds{0, 0, width, height}; HBRUSH background = CreateSolidBrush(color(239, 235, 222)); @@ -1728,19 +1453,12 @@ void draw_world(HDC dc, int width, int height) { DeleteObject(background); if (!world) return; - if ((!prefer_direct3d || !graphics.ready()) && height > map_top + map_footer) { - const int saved = SaveDC(dc); - if (saved != 0) { - IntersectClipRect(dc, 0, map_top, width, height - map_footer); - const auto offset = camera.offset(); - const auto scale = static_cast(camera.scale()); - const XFORM transform{scale, 0.0F, 0.0F, scale, - static_cast(offset.x), static_cast(offset.y)}; - if (SetGraphicsMode(dc, GM_ADVANCED) != 0 && SetWorldTransform(dc, &transform)) { - draw_map(dc, width); - } - RestoreDC(dc, saved); - } + if (!graphics.ready() && height > map_top + map_footer) { + RECT scene{16, map_top + 24, width - 16, height - map_footer}; + SetBkMode(dc, TRANSPARENT); + SetTextColor(dc, color(55, 68, 59)); + DrawTextW(dc, L"Не удалось запустить Direct3D 11. Откройте главное меню и войдите в колонию снова.", + -1, &scene, DT_CENTER | DT_WORDBREAK); } const RECT dock{0, height - map_footer, width, height}; @@ -1813,13 +1531,12 @@ LRESULT CALLBACK scene_window_proc(HWND window, UINT message, WPARAM wparam, LPA BeginPaint(window, &paint); RECT client{}; GetClientRect(window, &client); - const bool drawn = !world || !graphics.ready() || !prefer_direct3d || + const bool drawn = !world || !graphics.ready() || client.right <= 0 || client.bottom <= 0 || graphics.render(*world, scene_view(client.right, client.bottom)); EndPaint(window, &paint); if (!drawn) { graphics.reset(); - prefer_direct3d = false; const auto parent = GetParent(window); layout_scene(parent); invalidate_scene(parent); @@ -1829,88 +1546,50 @@ LRESULT CALLBACK scene_window_proc(HWND window, UINT message, WPARAM wparam, LPA return DefWindowProcW(window, message, wparam, lparam); } -void toggle_graphics(HWND window) { - if (prefer_direct3d && graphics.ready()) { - prefer_direct3d = false; - placement_message = L"Режим графики — изометрия GDI."; - } else { - prefer_direct3d = graphics.ready() || (scene_window && graphics.initialize(scene_window)); - placement_message = prefer_direct3d ? L"Режим графики — Direct3D 11." : - L"Direct3D 11 недоступен. Включена изометрия GDI."; - } - layout_scene(window); - invalidate_scene(window); -} +struct MenuAction { + int id; + const wchar_t* caption; + bool enabled = true; +}; -struct PauseMenu { - LanState lan_state; - bool paused; - bool scenario; - bool direct3d; +struct MenuDialog { + const wchar_t* title; + std::span actions; HBRUSH background; }; -INT_PTR CALLBACK pause_menu_proc(HWND dialog, UINT message, WPARAM wparam, LPARAM lparam) { +INT_PTR CALLBACK menu_dialog_proc(HWND dialog, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_INITDIALOG: { - const auto& menu = *reinterpret_cast(lparam); + const auto& menu = *reinterpret_cast(lparam); SetWindowLongPtrW(dialog, DWLP_USER, lparam); - const bool offline = menu.lan_state == LanState::Offline; - const bool host = menu.lan_state == LanState::Hosting || menu.lan_state == LanState::HostConnected; - const bool disconnected = menu.lan_state == LanState::GuestDisconnected; - SetWindowTextW(dialog, offline ? L"Меню паузы" : L"Меню игры"); - const auto control = [&](const wchar_t* type, const wchar_t* label, int id, DWORD flags, RECT rectangle) { - MapDialogRect(dialog, &rectangle); - const auto child = CreateWindowExW(0, type, label, WS_CHILD | WS_VISIBLE | flags, - rectangle.left, rectangle.top, rectangle.right - rectangle.left, rectangle.bottom - rectangle.top, - dialog, reinterpret_cast(static_cast(id)), GetModuleHandleW(nullptr), nullptr); + SetWindowTextW(dialog, menu.title); + HWND first_enabled = nullptr; + int y = 9; + for (const auto& action : menu.actions) { + RECT bounds{12, y, 218, y + 20}; + MapDialogRect(dialog, &bounds); + const auto child = CreateWindowExW(0, L"BUTTON", action.caption, + WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_OWNERDRAW, bounds.left, bounds.top, + bounds.right - bounds.left, bounds.bottom - bounds.top, dialog, + reinterpret_cast(static_cast(action.id)), GetModuleHandleW(nullptr), nullptr); SendMessageW(child, WM_SETFONT, reinterpret_cast(GetStockObject(DEFAULT_GUI_FONT)), TRUE); - return child; - }; - const auto button = [&](int id, const wchar_t* label, int column, int row, bool enabled = true) { - const int x = column == 0 ? 13 : 184; - const int y = 27 + row * 25; - const auto child = control(L"BUTTON", label, id, WS_TABSTOP | BS_OWNERDRAW, - {x, y, x + 155, y + 20}); - EnableWindow(child, enabled); - }; - control(L"STATIC", L"Поселение", -1, 0, {13, 9, 167, 23}); - control(L"STATIC", L"Кооператив", -1, 0, {184, 9, 339, 23}); - button(IDOK, L"Продолжить", 0, 0); - button(save_menu_id, L"Сохранить поселение…", 0, 1, offline || host); - button(load_menu_id, L"Загрузить поселение…", 0, 2, offline); - button(title_menu_id, L"Главное меню", 0, 3, offline); - button(graphics_menu_id, menu.direct3d ? L"Графика · Direct3D 11" : L"Графика · Изометрия GDI", 0, 4); - button(exit_menu_id, L"Выйти из игры", 0, 5); - if (offline) { - button(lan_host_id, L"Открыть для друга…", 1, 0, menu.scenario); - button(lan_join_id, L"Подключиться к другу…", 1, 1); - } else if (host) { - button(lan_info_id, L"Адрес и код партии…", 1, 0); - button(pause_button_id, menu.paused ? L"Продолжить для всех" : L"Пауза для всех", 1, 1); - button(lan_leave_id, L"Закрыть сетевую игру", 1, 2); - } else { - if (disconnected) button(lan_reconnect_id, L"Подключиться снова", 1, 0); - button(lan_leave_id, L"Выйти из сетевой игры", 1, 1); + EnableWindow(child, action.enabled); + if (!first_enabled && action.enabled) first_enabled = child; + y += 25; } - SetFocus(GetDlgItem(dialog, IDOK)); + SetFocus(first_enabled); return FALSE; } case WM_CTLCOLORDLG: - case WM_CTLCOLORSTATIC: - if (const auto* menu = reinterpret_cast(GetWindowLongPtrW(dialog, DWLP_USER))) { - const auto dc = reinterpret_cast(wparam); - SetTextColor(dc, color(236, 230, 205)); - SetBkMode(dc, TRANSPARENT); + if (const auto* menu = reinterpret_cast(GetWindowLongPtrW(dialog, DWLP_USER))) { return reinterpret_cast(menu->background); } break; case WM_DRAWITEM: if (const auto* item = reinterpret_cast(lparam); item && item->CtlType == ODT_BUTTON) { - WorkIcon icon = WorkIcon::Resident; - if (item->CtlID == graphics_menu_id) icon = WorkIcon::Stone; - else if (item->CtlID == save_menu_id || item->CtlID == load_menu_id) icon = WorkIcon::Crate; - draw_icon_button(*item, icon, item->CtlID == IDOK, true); + const bool storage = item->CtlID == save_menu_id || item->CtlID == load_menu_id; + draw_icon_button(*item, storage ? WorkIcon::Crate : WorkIcon::Resident, item->CtlID == IDOK, true); return TRUE; } break; @@ -1927,34 +1606,97 @@ INT_PTR CALLBACK pause_menu_proc(HWND dialog, UINT message, WPARAM wparam, LPARA return FALSE; } -void open_pause_menu(HWND window) { - if (!world || showing_title || pause_menu_open) return; - camera_drag.reset(); - if (GetCapture() == window) ReleaseCapture(); +int choose_menu_action(HWND window, const wchar_t* title, std::span actions) { struct alignas(DWORD) EmptyDialog { DLGTEMPLATE header{}; WORD menu = 0, window_class = 0, title = 0; } layout; layout.header.style = WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER; - layout.header.cx = 352; - layout.header.cy = 184; - PauseMenu menu{lan.state(), world->paused(), world->scenario_active(), prefer_direct3d && graphics.ready(), - CreateSolidBrush(color(34, 46, 40))}; - pause_menu_open = true; + layout.header.cx = 230; + layout.header.cy = static_cast(13 + 25 * actions.size()); + MenuDialog menu{title, actions, CreateSolidBrush(color(34, 46, 40))}; const auto action = DialogBoxIndirectParamW(GetModuleHandleW(nullptr), &layout.header, window, - pause_menu_proc, reinterpret_cast(&menu)); - if (action == IDOK) { - if (lan.state() == LanState::Offline && world->paused()) { + menu_dialog_proc, reinterpret_cast(&menu)); + DeleteObject(menu.background); + return static_cast(action); +} + +void open_pause_menu(HWND window) { + if (!world || showing_title || pause_menu_open) return; + camera_drag.reset(); + if (GetCapture() == window) ReleaseCapture(); + const bool offline = lan.state() == LanState::Offline; + const MenuAction actions[] = { + {IDOK, L"Продолжить"}, + {save_menu_id, L"Сохранить поселение…", !lan.is_guest()}, + {load_menu_id, L"Загрузить поселение…", offline}, + {title_menu_id, L"Главное меню"}, + {exit_menu_id, L"Выйти из игры"}, + }; + pause_menu_open = true; + const auto action = choose_menu_action(window, offline ? L"Меню паузы" : L"Меню игры", actions); + switch (action) { + case IDOK: + if (offline && world->paused()) { static_cast(send_command(settlement::CommandKind::SetPaused)); } - } else if (action != IDCANCEL && action != -1) { - SendMessageW(window, WM_COMMAND, static_cast(action), 0); + break; + case save_menu_id: + case load_menu_id: + handle_save_menu(window, action == save_menu_id); + break; + case title_menu_id: + show_title_screen(window, true); + refresh_lan_controls(window); + break; + case exit_menu_id: + DestroyWindow(window); + break; } pause_menu_open = false; - DeleteObject(menu.background); if (IsWindow(window)) SetFocus(window); } +void open_coop_menu(HWND window) { + std::vector actions; + switch (lan.state()) { + case LanState::Offline: + actions.push_back({lan_host_id, has_session && world && world->scenario_active() + ? L"Открыть текущую колонию для друга…" : L"Создать сетевую колонию…"}); + actions.push_back({lan_join_id, L"Подключиться к другу…"}); + break; + case LanState::Hosting: + case LanState::HostConnected: + actions.push_back({lan_info_id, L"Адрес и код партии…"}); + actions.push_back({pause_button_id, world->paused() ? L"Продолжить для всех" : L"Пауза для всех"}); + actions.push_back({lan_leave_id, L"Закрыть сетевую игру"}); + break; + case LanState::Connecting: + actions.push_back({lan_leave_id, L"Отменить подключение"}); + break; + case LanState::GuestDisconnected: + actions.push_back({lan_reconnect_id, L"Подключиться снова"}); + actions.push_back({lan_join_id, L"Подключиться к другу…"}); + [[fallthrough]]; + case LanState::GuestConnected: + actions.push_back({lan_leave_id, L"Выйти из сетевой игры"}); + break; + } + actions.push_back({IDCANCEL, L"Назад"}); + coop_menu_open = true; + const auto action = choose_menu_action(window, L"Кооператив", actions); + coop_menu_open = false; + if (action == pause_button_id && + (lan.state() == LanState::Hosting || lan.state() == LanState::HostConnected)) { + static_cast(send_command(settlement::CommandKind::SetPaused, {}, + static_cast(!world->paused()))); + placement_message = world->paused() ? L"Сетевая колония на паузе." : L"Сетевая колония продолжает работу."; + InvalidateRect(window, nullptr, FALSE); + } else if (action >= lan_host_id && action <= lan_leave_id) { + handle_lan_menu(window, action); + } +} + LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_GETMINMAXINFO: { @@ -2018,12 +1760,10 @@ LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lp if (const auto brush = title_screen.paint_list_background(reinterpret_cast(lparam), reinterpret_cast(wparam))) return reinterpret_cast(brush); } - if (LOWORD(wparam) == exit_menu_id && pause_menu_open) { - DestroyWindow(window); - return 0; - } - if (LOWORD(wparam) == graphics_menu_id && pause_menu_open) { - toggle_graphics(window); + break; + case WM_COMMAND: + if (showing_title) { + handle_title_command(window, LOWORD(wparam), HIWORD(wparam)); return 0; } if (LOWORD(wparam) == work_list_button_id && HIWORD(wparam) == BN_CLICKED && can_give_orders()) { @@ -2037,12 +1777,6 @@ LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lp SetFocus(window); return 0; } - break; - case WM_COMMAND: - if (showing_title) { - handle_title_command(window, LOWORD(wparam), HIWORD(wparam)); - return 0; - } if (LOWORD(wparam) == residents_button_id && HIWORD(wparam) == BN_CLICKED) { if (world) show_resident_roster(window); return 0; @@ -2068,10 +1802,6 @@ LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lp SendMessageW(window, WM_COMMAND, static_cast(choices[index].command), 0); return 0; } - if (LOWORD(wparam) >= lan_host_id && LOWORD(wparam) <= lan_leave_id) { - handle_lan_menu(window, LOWORD(wparam)); - return 0; - } if (LOWORD(wparam) >= berry_field_id && LOWORD(wparam) <= demolish_id) { if (!world || (lan.is_guest() && lan.state() != LanState::GuestConnected)) return 0; constexpr PlacementMode modes[] = {PlacementMode::BerryField, PlacementMode::TreePlot, @@ -2093,17 +1823,6 @@ LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lp invalidate_scene(window); return 0; } - if (LOWORD(wparam) == save_menu_id || LOWORD(wparam) == load_menu_id) { - handle_save_menu(window, LOWORD(wparam) == save_menu_id); - return 0; - } - if (LOWORD(wparam) == title_menu_id) { - if (lan.state() == LanState::Offline) { - show_title_screen(window, true); - refresh_lan_controls(window); - } - return 0; - } if (LOWORD(wparam) == cabin_button_id && HIWORD(wparam) == BN_CLICKED) { set_placement_mode(window, placement_mode == PlacementMode::Building ? PlacementMode::None : PlacementMode::Building); @@ -2126,19 +1845,11 @@ LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lp SetFocus(window); return 0; } - if (HIWORD(wparam) == BN_CLICKED && world && world->scenario_active()) { - if (LOWORD(wparam) == priority_button_id) { - const auto next = (static_cast(world->work_priority()) + 1U) % 3U; - static_cast(send_command(settlement::CommandKind::SetPriority, {}, static_cast(next))); - update_status(); - return 0; - } - if (LOWORD(wparam) == pause_button_id && pause_menu_open && !lan.is_guest()) { - static_cast(send_command(settlement::CommandKind::SetPaused, {}, - static_cast(!world->paused()))); - update_status(); - return 0; - } + if (LOWORD(wparam) == priority_button_id && HIWORD(wparam) == BN_CLICKED && world && world->scenario_active()) { + const auto next = (static_cast(world->work_priority()) + 1U) % 3U; + static_cast(send_command(settlement::CommandKind::SetPriority, {}, static_cast(next))); + update_status(); + return 0; } break; case WM_MOUSEWHEEL: { @@ -2311,12 +2022,16 @@ LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lp break; case WM_TIMER: if (wparam == timer_id && world) { - if (showing_title && lan.state() != LanState::Connecting) return 0; - if (!showing_title && !file_dialog_active && !lan.is_guest() && - (!pause_menu_open || lan.state() != LanState::Offline)) world->step(); + const auto state = lan.state(); + if (showing_title && (state == LanState::Offline || state == LanState::GuestDisconnected)) return 0; + if (!file_dialog_active && !lan.is_guest() && + (state != LanState::Offline || (!showing_title && !pause_menu_open))) world->step(); if (auto snapshot = lan.poll(*world)) { world = std::move(snapshot); - if (showing_title) show_title_screen(window, false); + has_session = true; + } + if (showing_title && enter_game_on_snapshot && !coop_menu_open && lan.state() == LanState::GuestConnected) { + show_title_screen(window, false); } sync_resident_roster(); if (lan.state() != displayed_lan_state) refresh_lan_controls(window); diff --git a/docs/roadmap-status.md b/docs/roadmap-status.md index 4291c83..587dec5 100644 --- a/docs/roadmap-status.md +++ b/docs/roadmap-status.md @@ -5,7 +5,7 @@ - Ядро симуляции с фиксированными тиками. - Пул потоков для выбора заданий, поиска маршрутов и продвижения жителей. - Автоматический выбор числа потоков в Windows-клиенте и параметр для командных бенчмарков. -- Изометрический прототип карты с жителями, заданиями и маршрутами. +- Объёмная карта с жителями, заданиями и маршрутами. - Базовый цикл ресурсов: источник дерева/камня → резервирование → добыча → перенос → склад. - Складской инвентарь со стеками `Wood` и `Stone` и учётом свободной вместимости. - Два рецепта превращают древесину в доски и камень в блоки. Домик строится из трёх досок и двух блоков. @@ -27,8 +27,8 @@ - Производительность ядра измерена на колониях с 50–500 жителями, полями, складами и ремеслом. Результаты и команда запуска описаны в [отчёте](../benchmarks/colony-performance.md). - Основные команды собраны в нижней панели «Жители», «Добыча», «Участки» и «Строительство». Меню «Работы» открывает те же команды по профессиям. - Главное меню открывается при запуске. В нём можно начать новую колонию, выбрать сохранение или подключиться к другу. -- Esc открывает меню паузы, сохранений, сетевых действий и графики. -- Direct3D 11 рисует карту, жителей и постройки как объёмную геометрию с глубиной. Изометрия GDI доступна через меню Esc. +- Esc открывает меню паузы и сохранений. Создание сетевой партии и подключение находятся в разделе «Кооператив» главного меню. +- Direct3D 11 рисует карту, жителей и постройки как объёмную геометрию с глубиной. - Поиск ресурсных работ отбирает подходящие поручения по профессиям. Повторные запросы путей используют кэш. - Движение, прогресс работ жителей и поиск маршрутов для общих заданий выполняются в пуле из двух и более потоков. Тесты проверяют игровые результаты, сохранения и команды кооператива. @@ -38,7 +38,7 @@ ## Ограничения прототипа -- Камера показывает карту в изометрической проекции. Direct3D использует базовые модели и затенение граней. +- Камера поддерживает перемещение и масштабирование. Direct3D использует базовые модели и затенение граней. - Каждый поход добытчика доставляет одну единицу сырья. Строитель везёт весь комплект для одного домика за рейс с остановками у нужных складов. Мастерские пока используют складское сырьё напрямую. - Свободный житель сначала ищет еду, если проголодался. Если порции нет, он может снова взять работу. При голоде здоровье пока остаётся прежним. - Завершённое спальное место назначается одному жителю. Сейчас жители идут спать по усталости. diff --git a/docs/viewer.md b/docs/viewer.md index 3b12278..48a4dbb 100644 --- a/docs/viewer.md +++ b/docs/viewer.md @@ -1,4 +1,4 @@ -# Запуск изометрического прототипа +# Запуск игры на Windows Соберите проект командой: @@ -14,7 +14,7 @@ powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\build.ps1 Колесо мыши приближает и отдаляет карту относительно курсора. Чтобы сдвинуть карту, перетащите её с зажатой левой или средней кнопкой мыши. Короткий щелчок левой кнопкой выбирает жителя или ставит чертёж. Home возвращает исходный вид. -Игра пробует включить Direct3D 11 при входе в колонию. Рендерер рисует объёмную карту с глубиной, постройки и жителей в изометрической проекции. Кнопка «Графика» в меню Esc переключает Direct3D и изометрию GDI. При ошибке устройства карта открывается в GDI. +Карту, постройки и жителей рисует Direct3D 11. Игра сначала пробует использовать видеокарту. Если устройство недоступно, Direct3D 11 пробует создать программное устройство WARP. В новой партии три поселенца. На нижней панели откройте «Строительство → Спальное место». Под кнопкой появятся «Дерево» слева и «Камень» справа. Выберите основу, затем щёлкайте по свободным клеткам. Выбранная основа применяется к следующим кроватям до выхода из режима или смены основы. Повторное нажатие «Спальное место» или правый щелчок завершает размещение. @@ -43,7 +43,7 @@ Esc открывает меню игры из любого режима стро ## Кооператив по локальной сети 1. Запустите одинаковую версию игры на двух компьютерах в одной локальной сети. -2. Хозяин открывает свою колонию через «Esc → Открыть для друга…» и передаёт гостю IPv4 и код партии. Порт игры — TCP 41727. -3. Гость выбирает «Подключиться к другу…» в главном меню или в меню Esc и вводит эти данные. При обрыве связи можно выбрать «Подключиться снова», пока хозяин оставляет партию открытой. +2. Хозяин открывает «Кооператив…» в главном меню и создаёт сетевую колонию либо открывает для друга уже начатую. Он передаёт гостю IPv4 и код партии. Затем он нажимает «Продолжить». Порт игры — TCP 41727. +3. Гость выбирает «Кооператив → Подключиться к другу…» в главном меню и вводит эти данные. При обрыве связи в этом же разделе можно выбрать «Подключиться снова», пока хозяин держит партию открытой. -Оба игрока строят и меняют задания в общей колонии. Меню Esc доступно каждому. Хозяин сохраняет игру и останавливает симуляцию кнопкой «Пауза для всех». После выхода гостя хозяин может продолжить партию. +Оба игрока строят и меняют задания в общей колонии. «Esc → Главное меню» позволяет открыть настройки кооператива и вернуться в колонию через «Продолжить». Хозяин сохраняет игру через Esc и может остановить симуляцию через «Кооператив → Пауза для всех» в главном меню.