From 6d1ac31dd0d60ed727f2bb8da93a414f652b5b9b Mon Sep 17 00:00:00 2001 From: wanotaitei Date: Mon, 2 Oct 2023 20:51:29 +0900 Subject: [PATCH] upd: Class to read input files. --- Library/PAX_GRAPHICA/InputFile.hpp | 95 +++++++++++++++++++ Library/PAX_GRAPHICA/Key.hpp | 4 +- Library/PAX_GRAPHICA/Window.hpp | 4 + Library/PAX_MAHOROBA/LocationPoint.hpp | 50 ++-------- Library/PAX_MAHOROBA/LocationRange.hpp | 7 ++ Library/PAX_MAHOROBA/MapViewer.hpp | 2 +- Library/PAX_MAHOROBA/StringViewer.hpp | 8 +- Library/PAX_MAHOROBA/XYZTiles.hpp | 38 ++++++-- Library/PAX_MAHOROBA/XYZTilesList.hpp | 73 +++++++++----- .../PAX_SAPIENTICA/Calendar/JapaneseEra.hpp | 32 ++----- Library/PAX_SAPIENTICA/Language.hpp | 26 +---- .../PAX_GRAPHICA/InputFileIncludeTest.cpp | 3 + .../GraphicalUserInterface.vcxproj | 1 + .../GraphicalUserInterface.vcxproj.filters | 3 + 14 files changed, 222 insertions(+), 124 deletions(-) create mode 100644 Library/PAX_GRAPHICA/InputFile.hpp create mode 100644 Project/IncludeTest/source/PAX_GRAPHICA/InputFileIncludeTest.cpp diff --git a/Library/PAX_GRAPHICA/InputFile.hpp b/Library/PAX_GRAPHICA/InputFile.hpp new file mode 100644 index 000000000..76fab67de --- /dev/null +++ b/Library/PAX_GRAPHICA/InputFile.hpp @@ -0,0 +1,95 @@ +/*########################################################################################## + + PAX SAPIENTICA Library 💀🌿🌏 + + [Planning] 2023 As Project + [Production] 2023 As Project + [Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA + [License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/ + +##########################################################################################*/ + +#ifndef PAX_GRAPHICA_INPUT_FILE_HPP +#define PAX_GRAPHICA_INPUT_FILE_HPP + +/*########################################################################################## + +##########################################################################################*/ + +#include +#include +#include + +#include + +namespace paxg { + + enum class InputFileType : unsigned char { + internal_file, // 内部 + external_file // 外部 + }; + + struct InputFile { + +#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB + int file_handle{ 0 }; + std::string pline{}; + std::string pline_tmp{}; +#else + std::ifstream pifs{}; + std::string pline{}; +#endif // PAXS_USING_DXLIB + + // ファイルが読み込まれたか確認する(読み込まれていない時は true ) + bool fail() const { +#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB + return (file_handle == 0); +#else + return pifs.fail(); +#endif // PAXS_USING_DXLIB + } + + // str_ ファイルのパスの文字列 + // default_path_ 基準となる根幹のパス + // type_ どこにファイルを保存するか + InputFile(const std::string& str_, const std::string& default_path_ = "", const InputFileType type_ = InputFileType::internal_file) { +#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB +#ifdef __ANDROID__ + file_handle = DxLib::FileRead_open(str_.c_str()); +#else + file_handle = DxLib::FileRead_open(std::string(default_path_ + str_).c_str()); +#endif // __ANDROID__ + DxLib::FileRead_set_format(file_handle, DX_CHARCODEFORMAT_UTF8); // UTF-8 を読み込む + if (file_handle != 0) { + pline.resize(4096); + pline_tmp.resize(4096); + } +#else + pifs = std::ifstream((default_path_.size() == 0) ? str_ : default_path_ + str_); // ファイルを読み込む +#endif + } + // 1 行読み込む + bool getLine() { +#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB + const int dline = DxLib::FileRead_gets(&(pline[0]), 4096, file_handle); + if (dline == -1) return false; + if (dline == 0) return false; + return true; +#else + return static_cast(std::getline(pifs, pline)); +#endif // PAXS_USING_DXLIB + } + // 区切り文字で分割する + std::vector split(const char delimiter) const { + return paxs::StringExtensions::split(pline, delimiter); + } + + std::string& lineString() { + return pline; + } + + }; + +} + +#endif // !PAX_GRAPHICA_INPUT_FILE_HPP diff --git a/Library/PAX_GRAPHICA/Key.hpp b/Library/PAX_GRAPHICA/Key.hpp index 5d771274e..a702474e9 100644 --- a/Library/PAX_GRAPHICA/Key.hpp +++ b/Library/PAX_GRAPHICA/Key.hpp @@ -207,10 +207,10 @@ namespace paxs { private: // 中央の座標を指定 Coordinate center = Coordinate( - paxs::EquirectangularDeg(paxs::Vector2(135.0, 35.0)), + paxs::EquirectangularDeg(paxs::Vector2(/*135.0, 35.0*/128,37)), //paxs::Vector2(135.0, getLatitudeToMercatorY(35.0)), 200.0); // マップ座標の中央 - double width = 180.0; // マップの幅 + double width = 12.0; // マップの幅 // 平城京 //Coordinate center = Coordinate(135.807, 37.009/*getLatitudeToMercatorY(35)*/, 200.0); // マップ座標の中央 diff --git a/Library/PAX_GRAPHICA/Window.hpp b/Library/PAX_GRAPHICA/Window.hpp index cbfecd423..677b4d6ba 100644 --- a/Library/PAX_GRAPHICA/Window.hpp +++ b/Library/PAX_GRAPHICA/Window.hpp @@ -131,6 +131,7 @@ namespace paxg { #else // その他の処理 (Windows) DxLib::GetWindowSize(&width, &height); + // DxLib::GetWindowSize(&width, &height); #endif return Vec2i{ static_cast(width / 2) ,static_cast(height / 2) }; @@ -160,6 +161,7 @@ namespace paxg { #else // その他の処理 (Windows) DxLib::GetWindowSize(&width, &height); + // DxLib::GetWindowSize(&width, &height); #endif return static_cast(width); @@ -188,6 +190,7 @@ namespace paxg { #else // その他の処理 (Windows) DxLib::GetWindowSize(&width, &height); + // DxLib::GetWindowSize(&width, &height); #endif return static_cast(height); @@ -216,6 +219,7 @@ namespace paxg { #else // その他の処理 (Windows) DxLib::GetWindowSize(&width, &height); + // DxLib::GetWindowSize(&width, &height); #endif return Vec2i{ static_cast(width) ,static_cast(height) }; diff --git a/Library/PAX_MAHOROBA/LocationPoint.hpp b/Library/PAX_MAHOROBA/LocationPoint.hpp index 5543a0166..cc1d1a6bd 100644 --- a/Library/PAX_MAHOROBA/LocationPoint.hpp +++ b/Library/PAX_MAHOROBA/LocationPoint.hpp @@ -23,6 +23,7 @@ #include #include // 地図投影法 +#include #include #include #include @@ -114,6 +115,8 @@ namespace paxs { inputPlace(std::string("Data/PlaceName/TohokuAynu.tsv")); // 渤海 inputPlace(std::string("Data/PlaceName/Balhae.tsv")); + // 統一新羅 + inputPlace(std::string("Data/PlaceName/UnifiedSilla.tsv")); // 倭名類聚抄の地名 inputPlace(std::string("Data/PlaceName/WamyoRuijushoPlaceName.tsv")); // 倭名類聚抄の地名 @@ -347,50 +350,13 @@ namespace paxs { // 地名を読み込み void inputPlace(const std::string& str_, const LocationPointEnum lpe_ = LocationPointEnum::location_point_place_name) { -#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB -#ifdef __ANDROID__ - const int file_handle = DxLib::FileRead_open(str_.c_str()); -#else - const int file_handle = DxLib::FileRead_open(std::string(PAXS_PATH + str_).c_str()); -#endif // __ANDROID__ - DxLib::FileRead_set_format(file_handle, DX_CHARCODEFORMAT_UTF8); - if (file_handle == 0) return; - std::string pline{}; - pline.resize(4096); - std::string pline_tmp{}; - pline_tmp.resize(4096); -#else - std::ifstream pifs(PAXS_PATH + str_); // 地名を読み込む + paxg::InputFile pifs(str_, PAXS_PATH); if (pifs.fail()) return; - std::string pline; -#endif -#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB - while (true) { - const int dline = DxLib::FileRead_gets(&(pline[0]), 4096, file_handle); - - if (dline == -1) break; - if (dline == 0) break; - - // const std::string pline = std::string(pline0.c_str()); - std::vector strvec{}; - - std::string str_p{}; - for (int i = 0, pi = 0; i <= dline; ++i) { - if (pline[i] == '\0') continue; - if (pline[i] == '\t' || i == dline) { - strvec.emplace_back(str_p); - str_p.clear(); - } - else { - str_p.push_back(pline[i]); - } - } - strvec.emplace_back(str_p); -#else + // 1 行ずつ読み込み(区切りはタブ) - while (std::getline(pifs, pline)) { - std::vector strvec = paxs::StringExtensions::split(pline, '\t'); -#endif + while (pifs.getLine()) { + std::vector strvec = pifs.split('\t'); + // 格納 location_point_list.emplace_back( strvec[0], // 漢字 diff --git a/Library/PAX_MAHOROBA/LocationRange.hpp b/Library/PAX_MAHOROBA/LocationRange.hpp index c1cf57a59..491a9d9ca 100644 --- a/Library/PAX_MAHOROBA/LocationRange.hpp +++ b/Library/PAX_MAHOROBA/LocationRange.hpp @@ -46,6 +46,13 @@ namespace paxs { TextureLocation() { // ここに実験用のテクスチャを定義する + //// 統一新羅 朝鮮半島 + //location_range_list.emplace_back("./../../../../../Data/Map/TestMap/a.png", + // 124.6, + // MapProjectionF64::equirectangularDegYToMercatorDegY(34.25), + // 129.65, + // MapProjectionF64::equirectangularDegYToMercatorDegY(39.4)); + //location_range_list.emplace_back("./../../../../../Data/Map/TestMap/nara.png", // 135.7104, // MapProjectionF64::equirectangularDegYToMercatorDegY(34.59451), diff --git a/Library/PAX_MAHOROBA/MapViewer.hpp b/Library/PAX_MAHOROBA/MapViewer.hpp index c0903d1a5..9b1b20ae4 100644 --- a/Library/PAX_MAHOROBA/MapViewer.hpp +++ b/Library/PAX_MAHOROBA/MapViewer.hpp @@ -105,7 +105,7 @@ namespace paxs { paxs::GraphicVisualizationList& visible ) { map_view->update(); // キーボード入力を更新 - mapMapUpdate(xyz_tile_list, string_siv.menu_bar, map_view.get()); // 地図の辞書を更新 + mapMapUpdate(xyz_tile_list, string_siv.menu_bar, map_view.get(), koyomi_siv.jdn.cgetDay()); // 地図の辞書を更新 if (visible["Map"]) { // 地図上に画像を描画する diff --git a/Library/PAX_MAHOROBA/StringViewer.hpp b/Library/PAX_MAHOROBA/StringViewer.hpp index 7a6488e6d..1986076c1 100644 --- a/Library/PAX_MAHOROBA/StringViewer.hpp +++ b/Library/PAX_MAHOROBA/StringViewer.hpp @@ -210,7 +210,11 @@ namespace paxs { if (visible["Calendar"]) { #ifdef PAXS_USING_DXLIB - paxg::Rect{ paxg::Vec2i(rect_start_x, koyomi_font_y - 5), paxg::Vec2i(360, next_rect_start_y) }.draw(); + DxLib::DrawRoundRect(rect_start_x, koyomi_font_y - 5, + rect_start_x + 360, koyomi_font_y - 5 + next_rect_start_y, + 10, 10, DxLib::GetColor(255, 255, 255), TRUE); + + // paxg::Rect{ paxg::Vec2i(rect_start_x, koyomi_font_y - 5), paxg::Vec2i(360, next_rect_start_y) }.draw(); // paxg::Rect{ paxg::Vec2i(rect_start_x, koyomi_font_y + next_rect_start_y + 5), paxg::Vec2i(360, next_rect_end_y) }.draw(); #endif // PAXS_USING_DXLIB @@ -257,11 +261,9 @@ namespace paxs { case paxs::cal::DateOutputType::name_and_ymd: koyomi_font[select_language.cget()].drawTopRight(std::string(koyomi_siv.date_list[i].calendar_name[select_language.cget() + 1 /* 言語位置調整 */]), paxg::Vec2i(static_cast(koyomi_font_x), static_cast(koyomi_font_y + i * (koyomi_font_size * 4 / 3))), paxg::Color(0, 0, 0)); -#ifndef PAXS_USING_DXLIBa koyomi_font[select_language.cget()].drawTopRight(reinterpret_cast(u8"年"), paxg::Vec2i(static_cast(int(120 * koyomi_font_size / 30.0) + koyomi_font_x), static_cast(koyomi_font_y + i * (koyomi_font_size * 4 / 3))), paxg::Color(0, 0, 0)); koyomi_font[select_language.cget()].drawTopRight(reinterpret_cast(u8"月"), paxg::Vec2i(static_cast(int(220 * koyomi_font_size / 30.0) + koyomi_font_x), static_cast(koyomi_font_y + i * (koyomi_font_size * 4 / 3))), paxg::Color(0, 0, 0)); koyomi_font[select_language.cget()].drawTopRight(reinterpret_cast(u8"日"), paxg::Vec2i(static_cast(int(300 * koyomi_font_size / 30.0) + koyomi_font_x), static_cast(koyomi_font_y + i * (koyomi_font_size * 4 / 3))), paxg::Color(0, 0, 0)); -#endif std::visit([&](const auto& x) { date_year = int(x.cgetYear()); date_month = int(x.cgetMonth()); diff --git a/Library/PAX_MAHOROBA/XYZTiles.hpp b/Library/PAX_MAHOROBA/XYZTiles.hpp index 7613fd519..e665f1046 100644 --- a/Library/PAX_MAHOROBA/XYZTiles.hpp +++ b/Library/PAX_MAHOROBA/XYZTiles.hpp @@ -30,6 +30,9 @@ #include #include +#include +#include + namespace paxs { class XYZTile { @@ -60,7 +63,7 @@ namespace paxs { std::unordered_map texture{}; std::uint_least64_t textureIndex(const MapVec4D& m_) const { - return (m_.y) + (m_.x << 24) + (m_.z << 48);// +(m_.layer << 53); + return (m_.y) + (m_.x << 24) + (m_.z << 48); // +(m_.layer << 53); } XYZTile() @@ -152,6 +155,7 @@ namespace paxs { + std::string(".png")); break; case XYZTileFileName::Z_Original: + new_saveFilePath = map_file_path_name; new_saveFilePath = (map_file_path_name + std::to_string(z) + std::string("/") + map_name + std::string("_") + std::to_string(z) @@ -186,12 +190,17 @@ namespace paxs { #if defined(PAXS_USING_SIV3D) // URL の記載がある場合 if (map_url_name.size() != 0) { - const s3d::URL new_url = - s3d::String(s3d::Unicode::FromUTF8(map_url_name)) - + s3d::String(U"/") + s3d::ToString(z) - + s3d::String(U"/") + s3d::ToString((j + z_num) % z_num) - + s3d::String(U"/") + s3d::ToString((i + z_num) % z_num) - + s3d::String(U".png"); + std::string new_path = map_url_name; + paxs::StringExtensions::replace(new_path, "{x}", std::to_string((j + z_num) % z_num)); + paxs::StringExtensions::replace(new_path, "{y}", std::to_string((i + z_num) % z_num)); + paxs::StringExtensions::replace(new_path, "{z}", std::to_string(z)); + const s3d::URL new_url = s3d::Unicode::FromUTF8(new_path); + //const s3d::URL new_url = + // s3d::String(s3d::Unicode::FromUTF8(map_url_name)) + // + s3d::String(U"/") + s3d::ToString(z) + // + s3d::String(U"/") + s3d::ToString((j + z_num) % z_num) + // + s3d::String(U"/") + s3d::ToString((i + z_num) % z_num) + // + s3d::String(U".png"); if (s3d::SimpleHTTP::Save(new_url, s3d::Unicode::FromUTF8(new_saveFilePath)).isOK()) { // texture_list[k] = paxg::Texture{ new_saveFilePath }; @@ -254,12 +263,15 @@ namespace paxs { } } } - void draw(const double map_view_width, const double map_view_height, const double map_view_center_x, const double map_view_center_y + void draw(const double map_view_width, const double map_view_height, const double map_view_center_x, const double map_view_center_y, const int date )const { // 拡大率が描画範囲外の場合はここで処理を終了 if (magnification_z < draw_min_z) return; if (magnification_z > draw_max_z) return; + // 描画する期間じゃない場合はここで処理を終了 + if (min_date != 99999999 && min_date > date) return; + if (max_date != 99999999 && max_date < date) return; // 描画する場所がない場合は無視 if (pos_list2.size() == 0) return; @@ -356,6 +368,12 @@ namespace paxs { void setDrawMaxZ(const int max_z_) { draw_max_z = max_z_; } + void setMinDate(const int min_date_) { + min_date = min_date_; + } + void setMaxDate(const int max_date_) { + max_date = max_date_; + } void setMapURL(const std::string& map_url_name_) { map_url_name = map_url_name_; } @@ -366,6 +384,10 @@ namespace paxs { map_file_path_name = map_file_path_name_; } private: + // 99999999 の場合は固定なし + int min_date = 99999999; + int max_date = 99999999; + // 固定された Z ( 999 の場合は固定なし ) int default_z = 999; // 最小 Z diff --git a/Library/PAX_MAHOROBA/XYZTilesList.hpp b/Library/PAX_MAHOROBA/XYZTilesList.hpp index f2d6b3cd3..94288d867 100644 --- a/Library/PAX_MAHOROBA/XYZTilesList.hpp +++ b/Library/PAX_MAHOROBA/XYZTilesList.hpp @@ -91,6 +91,19 @@ namespace paxs { xyz_tile_list.emplace("map_land_and_water", *xyz_tile2); } + //{ + // const std::unique_ptr xyz_tile_gmaps(new(std::nothrow) XYZTile( + // map_view->getWidth(), map_view->getHeight(), map_view->getCenterX(), map_view->getCenterY(), + // paxs::XYZTile::XYZTileFileName::Z_Original)); + // //xyz_tile_gmaps->setMapURL("https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}"); + // xyz_tile_gmaps->setMapURL("http://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png"); + // xyz_tile_gmaps->setMapName("map"); + // // xyz_tile_gmaps->setDefaultZ(12); + // // xyz_tile_gmaps->setDrawMinZ(11); + // xyz_tile_gmaps->setMapFilePath(path + "Data/Map/XYZTile/GoogleMaps/"); + + // xyz_tile_list.emplace("map_gmaps", *xyz_tile_gmaps); + //} { // const std::unique_ptr xyz_tile3(new(std::nothrow) XYZTile( // map_view->getWidth(), map_view->getHeight(), map_view->getCenterX(), map_view->getCenterY(), @@ -145,6 +158,8 @@ namespace paxs { xyz_tile_kuni_korean_line->setMinZ(7); xyz_tile_kuni_korean_line->setMaxZ(8); xyz_tile_kuni_korean_line->setDrawMinZ(6); + xyz_tile_kuni_korean_line->setMinDate(1872272); // J 414-01-01 + xyz_tile_kuni_korean_line->setMaxDate(1915370); // J 532-01-01 - 1 xyz_tile_kuni_korean_line->setMapFilePath(path + "Data/Map/XYZTile/KoreanLine/"); xyz_tile_list.emplace("map_korean_line", *xyz_tile_kuni_korean_line); @@ -158,6 +173,8 @@ namespace paxs { xyz_tile_kuni_balhae_line->setMinZ(5); xyz_tile_kuni_balhae_line->setMaxZ(8); xyz_tile_kuni_balhae_line->setDrawMinZ(3); + xyz_tile_kuni_balhae_line->setMinDate(1976003); // J 698-01-01 + xyz_tile_kuni_balhae_line->setMaxDate(2059279); // J 926-01-01 - 1 xyz_tile_kuni_balhae_line->setMapFilePath(path + "Data/Map/XYZTile/BalhaeLine/"); xyz_tile_list.emplace("map_balhae_line", *xyz_tile_kuni_balhae_line); @@ -268,7 +285,8 @@ namespace paxs { void mapMapUpdate( std::unordered_map& xyz_tile_list, const paxs::MenuBar& menu_bar, - const MapView* const map_view) { + const MapView* const map_view, + cal::JDN_F64 jdn) { const double map_view_width = map_view->getWidth(); const double map_view_height = map_view->getHeight(); @@ -279,16 +297,16 @@ namespace paxs { // タイルを更新 // xyz_tile1"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); - if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::base)) { + if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::base)) { xyz_tile_list["map_base"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } - if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::soil)) { + if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::soil)) { xyz_tile_list["map_soil"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } - if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::soil_temperature)) { + if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::soil_temperature)) { xyz_tile_list["map_soil_temperature"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } - if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::land_and_water)) { + if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::land_and_water)) { xyz_tile_list["map_land_and_water"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } // xyz_tile3"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); @@ -307,6 +325,9 @@ namespace paxs { if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::slope)) { xyz_tile_list["map_slope"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } + if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::slope)) { + xyz_tile_list["map_gmaps"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + } if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::river1)) { xyz_tile_list["map_river"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } @@ -320,7 +341,7 @@ namespace paxs { // if (menu_bar.getPulldown(MenuBarType::map).getIsItems(MapType::line2)) { // xyz_tile_list["map_line2"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); // } - if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::line2)) { + if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::line2)) { xyz_tile_list["map_line3"].update(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } /*########################################################################################## @@ -330,45 +351,51 @@ namespace paxs { // if (menu_bar_view.getIsItems(1)) { if (menu_bar.cgetPulldown(MenuBarType::view).getIsItems(1)) { + + const int date = static_cast(jdn.cgetDay()); + // XYZ タイルの地図の描画 - // xyz_tile1"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + // xyz_tile1"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::base)) { - if (xyz_tile_list.find("map_base") != xyz_tile_list.end()) xyz_tile_list.at("map_base").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_base") != xyz_tile_list.end()) xyz_tile_list.at("map_base").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::soil)) { - if (xyz_tile_list.find("map_soil") != xyz_tile_list.end()) xyz_tile_list.at("map_soil").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_soil") != xyz_tile_list.end()) xyz_tile_list.at("map_soil").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::land_and_water)) { - if (xyz_tile_list.find("map_land_and_water") != xyz_tile_list.end()) xyz_tile_list.at("map_land_and_water").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_land_and_water") != xyz_tile_list.end()) xyz_tile_list.at("map_land_and_water").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::soil_temperature)) { - if (xyz_tile_list.find("map_soil_temperature") != xyz_tile_list.end()) xyz_tile_list.at("map_soil_temperature").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_soil_temperature") != xyz_tile_list.end()) xyz_tile_list.at("map_soil_temperature").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } - // xyz_tile2"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + // xyz_tile2"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::slope)) { - if (xyz_tile_list.find("map_slope") != xyz_tile_list.end()) xyz_tile_list.at("map_slope").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_slope") != xyz_tile_list.end()) xyz_tile_list.at("map_slope").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); + } + if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::slope)) { + if (xyz_tile_list.find("map_gmaps") != xyz_tile_list.end()) xyz_tile_list.at("map_gmaps").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::river1)) { - if (xyz_tile_list.find("map_river") != xyz_tile_list.end()) xyz_tile_list.at("map_river").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_river") != xyz_tile_list.end()) xyz_tile_list.at("map_river").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::river2)) { - if (xyz_tile_list.find("map_river_bw") != xyz_tile_list.end()) xyz_tile_list.at("map_river_bw").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_river_bw") != xyz_tile_list.end()) xyz_tile_list.at("map_river_bw").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::ryosei_country)) { - if (xyz_tile_list.find("map_ryosei") != xyz_tile_list.end()) xyz_tile_list.at("map_ryosei").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_ryosei") != xyz_tile_list.end()) xyz_tile_list.at("map_ryosei").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::ryosei_line)) { - if (xyz_tile_list.find("map_ryosei_line") != xyz_tile_list.end()) xyz_tile_list.at("map_ryosei_line").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_ryosei_line") != xyz_tile_list.end()) xyz_tile_list.at("map_ryosei_line").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::ryosei_line)) { - if (xyz_tile_list.find("map_korean_line") != xyz_tile_list.end()) xyz_tile_list.at("map_korean_line").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_korean_line") != xyz_tile_list.end()) xyz_tile_list.at("map_korean_line").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::ryosei_line)) { - if (xyz_tile_list.find("map_balhae_line") != xyz_tile_list.end()) xyz_tile_list.at("map_balhae_line").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + if (xyz_tile_list.find("map_balhae_line") != xyz_tile_list.end()) xyz_tile_list.at("map_balhae_line").draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } - // xyz_tile3"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); - // xyz_tile4"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + // xyz_tile3"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); + // xyz_tile4"].draw(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); // if (menu_bar.getPulldown(MenuBarType::map).getIsItems(MapType::line1)) { // xyz_tile_list.at("map_line").drawLine(map_view_width, map_view_height, map_view_center_x, map_view_center_y, 0.8, paxg::Color{ 95,99,104 }); // } @@ -379,9 +406,9 @@ namespace paxs { if (xyz_tile_list.find("map_line3") != xyz_tile_list.end()) xyz_tile_list.at("map_line3").drawLine(map_view_width, map_view_height, map_view_center_x, map_view_center_y, 0.8, paxg::Color{ 95, 99, 104 }); if (xyz_tile_list.find("map_line3") != xyz_tile_list.end()) xyz_tile_list.at("map_line3").drawXYZ(map_view_width, map_view_height, map_view_center_x, map_view_center_y); } - if (menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::line2)) { + if (!menu_bar.cgetPulldown(MenuBarType::map).getIsItems(MapType::line2)) { // xyz_tile_list.at("map_line4").drawLine(map_view_width, map_view_height, map_view_center_x, map_view_center_y, 0.8, paxg::Color{ 95, 99, 104 }); - // xyz_tile_list.at("map_line4").drawXYZ(map_view_width, map_view_height, map_view_center_x, map_view_center_y); + // xyz_tile_list.at("map_line4").drawXYZ(map_view_width, map_view_height, map_view_center_x, map_view_center_y, date); } } diff --git a/Library/PAX_SAPIENTICA/Calendar/JapaneseEra.hpp b/Library/PAX_SAPIENTICA/Calendar/JapaneseEra.hpp index bcb0ed964..589fbb132 100644 --- a/Library/PAX_SAPIENTICA/Calendar/JapaneseEra.hpp +++ b/Library/PAX_SAPIENTICA/Calendar/JapaneseEra.hpp @@ -24,6 +24,8 @@ #include +#include + namespace paxs { // 日本の元号 @@ -65,32 +67,14 @@ namespace paxs { /// @param japanese_era_list 元号リスト /// @param path 元号一覧のファイルパス static void inputList(std::vector& japanese_era_list, const std::string& path){ -#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB - const int file_handle = DxLib::FileRead_open(path.c_str()); - DxLib::FileRead_set_format(file_handle, DX_CHARCODEFORMAT_UTF8); - if (file_handle == 0) return; - std::string pline{}; - pline.resize(4096); - std::string pline_tmp{}; - pline_tmp.resize(4096); -#else - std::ifstream pifs(path); // 地名を読み込む + + paxg::InputFile pifs(path); if (pifs.fail()) return; - std::string pline; -#endif -#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB - const int dline0 = DxLib::FileRead_gets(&(pline[0]), 4096, file_handle); - if (dline0 == -1 || dline0 == 0) {} // 最初は破棄 - else while (true) { - const int dline = DxLib::FileRead_gets(&(pline[0]), 4096, file_handle); - if (dline == -1) break; - if (dline == 0) break; -#else - std::getline(pifs, pline); // 最初は破棄 + pifs.getLine(); // 最初は破棄 + // 1 行ずつ読み込み(区切りはタブ) - while (std::getline(pifs, pline)) { -#endif - std::vector strvec = paxs::StringExtensions::split(pline, '\t'); + while (pifs.getLine()) { + std::vector strvec = pifs.split('\t'); japanese_era_list.emplace_back( std::array({ diff --git a/Library/PAX_SAPIENTICA/Language.hpp b/Library/PAX_SAPIENTICA/Language.hpp index 8d5c71340..303af8341 100644 --- a/Library/PAX_SAPIENTICA/Language.hpp +++ b/Library/PAX_SAPIENTICA/Language.hpp @@ -23,6 +23,8 @@ #include #include +#include + namespace paxs { // 選択言語 @@ -64,29 +66,11 @@ namespace paxs { } // 新しいテキストの追加 void add(const std::string& str_) { -#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB - const int file_handle = DxLib::FileRead_open(str_.c_str()); - DxLib::FileRead_set_format(file_handle, DX_CHARCODEFORMAT_UTF8); - if (file_handle == 0) return; - std::string pline{}; - pline.resize(4096); - std::string pline_tmp{}; - pline_tmp.resize(4096); -#else - std::ifstream pifs(str_); // テキストを読み込む + paxg::InputFile pifs(str_); if (pifs.fail()) return; - std::string pline; -#endif -#ifdef PAXS_USING_DXLIB // PAXS_USING_DXLIB - while (true) { - const int dline = DxLib::FileRead_gets(&(pline[0]), 4096, file_handle); - if (dline == -1) break; - if (dline == 0) break; -#else // 1 行ずつ読み込み(区切りはタブ) - while (std::getline(pifs, pline)) { -#endif - split(pline, '\t'); + while (pifs.getLine()) { + split(pifs.lineString(), '\t'); } if (text.size() == 0) { empty.resize(0); diff --git a/Project/IncludeTest/source/PAX_GRAPHICA/InputFileIncludeTest.cpp b/Project/IncludeTest/source/PAX_GRAPHICA/InputFileIncludeTest.cpp new file mode 100644 index 000000000..e823e9e78 --- /dev/null +++ b/Project/IncludeTest/source/PAX_GRAPHICA/InputFileIncludeTest.cpp @@ -0,0 +1,3 @@ +#include + +int main(){} diff --git a/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj b/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj index 5b0a64724..dfcf165b0 100644 --- a/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj +++ b/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj @@ -322,6 +322,7 @@ + diff --git a/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj.filters b/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj.filters index b0a7e9af3..06c4808a3 100644 --- a/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj.filters +++ b/Project/MapViewer/Windows/GraphicalUserInterface/GraphicalUserInterface.vcxproj.filters @@ -860,5 +860,8 @@ Library\Mahoroba + + Library\Graphica + \ No newline at end of file