Skip to content

Commit

Permalink
Merge pull request #50 from AsPJT/feature-ref-gui
Browse files Browse the repository at this point in the history
テクスチャの読み込み速度の向上
  • Loading branch information
AsPJT authored Sep 25, 2023
2 parents 61dec0d + af9c4b5 commit ba93ee7
Show file tree
Hide file tree
Showing 23 changed files with 291 additions and 273 deletions.
Binary file added Data/MiniIcon/HotategaiGataKofun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/MiniIcon/ZempoKoenFun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/MiniIcon/ZempoKohoFun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion Data/PlaceName/Ryoseikoku.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,6 @@
陸奧國 Mutsu 140.892883 38.222328 1 24 1968011 9999999 None
出羽 Dewa 139.908697 38.963655 1 16 1721424 1979972 None
出羽郡 Dewa 139.908697 38.963655 1 16 1979973 1981415 None
出羽國 Dewa 139.908697 38.963655 1 16 1981416 9999999 None
出羽國 Dewa 139.908697 38.963655 1 16 1981416 9999999 None
三内 Sannai 140.703621 40.817090 1 24 1721424 9999999 None
ポロノッ Poro-not 145.5825 43.3352778 1 24 1721424 9999999 None
22 changes: 22 additions & 0 deletions Library/PAX_GRAPHICA/Rect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,28 @@ namespace paxg {
DxLib::GetColor(c_.r, c_.g, c_.b), TRUE);
#endif
}
void drawAt() const {
#if defined(PAXS_USING_SIV3D)
// rect.draw();
#elif defined(PAXS_USING_SFML)
Window::window.draw(rect);
#elif defined(PAXS_USING_DXLIB)
DxLib::DrawBox(
static_cast<int>(x0 - w0 / 2), static_cast<int>(y0 - h0 / 2), static_cast<int>(x0 + w0 / 2), static_cast<int>(y0 + h0 / 2),
DxLib::GetColor(255, 255, 255), TRUE);
#endif
}
void drawAt(const paxg::Color& c_) const {
#if defined(PAXS_USING_SIV3D)
// rect.draw(c_.color);
#elif defined(PAXS_USING_SFML)
Window::window.draw(c_);
#elif defined(PAXS_USING_DXLIB)
DxLib::DrawBox(
static_cast<int>(x0 - w0 / 2), static_cast<int>(y0 - h0 / 2), static_cast<int>(x0 + w0 / 2), static_cast<int>(y0 + h0 / 2),
DxLib::GetColor(c_.r, c_.g, c_.b), TRUE);
#endif
}

void drawFrame(const double inner_thickness, const double outer_thickness, const paxg::Color& color_) const {
#if defined(PAXS_USING_SIV3D)
Expand Down
10 changes: 6 additions & 4 deletions Library/PAX_GRAPHICA/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,31 +163,33 @@ namespace paxg {
}

void drawBottomLeft(const std::string& str, const paxg::Vec2i& pos, const paxg::Color& color) const {
DxLib::DrawFormatString(pos.x(), pos.y(), DxLib::GetColor(color.r, color.g, color.b), str.c_str());
DxLib::DrawFormatString(pos.x(), pos.y() - 10, DxLib::GetColor(color.r, color.g, color.b), str.c_str());
// DxLib::DrawStringToHandle(pos.x(), pos.y(), str.c_str(), DxLib::GetColor(color.r, color.g, color.b), font);
}
void drawTopRight(const std::string& str, const paxg::Vec2i& pos, const paxg::Color& color) const {
// printfDx("%s, x%d, y%d, r%d, g%d, b%d, f%d\n", str.c_str(), pos.x(), pos.y(), color.r, color.g, color.b, font);
int dswth = DxLib::GetDrawStringWidthToHandle(str.c_str(), int(str.size()), font);
int dsw = DxLib::GetDrawStringWidth(str.c_str(), int(str.size()));
// printfDx("dswth:%d, dsw:%d\n", dswth, dsw);
DxLib::DrawFormatString(pos.x() - 300, pos.y(), DxLib::GetColor(color.r, color.g, color.b), str.c_str());
DxLib::DrawFormatString(pos.x(), pos.y() + 10, DxLib::GetColor(color.r, color.g, color.b), str.c_str());
// DxLib::DrawFormatString(pos.x() - 300, pos.y(), DxLib::GetColor(color.r, color.g, color.b), str.c_str());

}
void draw(const std::string& str, const paxg::Vec2i& pos, const paxg::Color& color) const {
DxLib::DrawFormatString(pos.x(), pos.y(), DxLib::GetColor(color.r, color.g, color.b), str.c_str());
// DxLib::DrawStringToHandle(pos.x(), pos.y(), str.c_str(), DxLib::GetColor(color.r, color.g, color.b), font);
}
void drawBottomCenter(const std::string& str, const paxg::Vec2i& pos, const paxg::Color& color) const {
DxLib::DrawFormatString(pos.x(), pos.y(), DxLib::GetColor(color.r, color.g, color.b), str.c_str());
DxLib::DrawFormatString(pos.x(), pos.y() - 10, DxLib::GetColor(color.r, color.g, color.b), str.c_str());
// DxLib::DrawStringToHandle(pos.x(), pos.y(), str.c_str(), DxLib::GetColor(color.r, color.g, color.b), font);
}
void drawTopCenter(const std::string& str, const paxg::Vec2i& pos, const paxg::Color& color) const {
// printfDx("%s, x%d, y%d, r%d, g%d, b%d, f%d\n", str.c_str(), pos.x(), pos.y(), color.r, color.g, color.b, font);
int dswth = DxLib::GetDrawStringWidthToHandle(str.c_str(), int(str.size()), font);
int dsw = DxLib::GetDrawStringWidth(str.c_str(), int(str.size()));
// printfDx("dswth:%d, dsw:%d\n", dswth, dsw);
DxLib::DrawFormatString(pos.x() - 300, pos.y(), DxLib::GetColor(color.r, color.g, color.b), str.c_str());
DxLib::DrawFormatString(pos.x(), pos.y() + 10, DxLib::GetColor(color.r, color.g, color.b), str.c_str());
// DxLib::DrawFormatString(pos.x() - 300, pos.y(), DxLib::GetColor(color.r, color.g, color.b), str.c_str());

}
void drawAt(const std::string& str, const paxg::Vec2i& pos, const paxg::Color& color) const {
Expand Down
4 changes: 2 additions & 2 deletions Library/PAX_SAPIENTICA/Siv3D/Calendar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace paxs {
"Jul.","Aug.","Sep.","Oct.","Nov.","Dec." };


bool move_forward_in_time = false; // 時間を進めるか
bool move_forward_in_time = true; // デバッグ false; // 時間を進めるか
bool go_back_in_time = false; // 時間を戻すか
bool is_agent_update = true; // エージェントの更新をするか

Expand Down Expand Up @@ -178,7 +178,7 @@ namespace paxs {

static int calendar_update_counter = 0; // 暦を繰り上げるタイミングを決めるためのカウンタ
++calendar_update_counter;
//if(move_forward_in_time) jdn += 1000;
if (move_forward_in_time) jdn.getDay() += 1.0; // デバッグ
//else if(go_back_in_time) jdn -= 1000;
//if (count >= 0) {
if (calendar_update_counter >= 30) { // カウンタが指定した値を超えたら日付を変える処理を実行
Expand Down
8 changes: 7 additions & 1 deletion Library/PAX_SAPIENTICA/Siv3D/InitLogo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ namespace paxs {
// ソフトウェアを実行した最初のフレームの一番最初に実行
static void firstInit(const std::string& path8) {
// ロゴ画像の読み込み
const paxg::Texture texture_tl{ path8 + "Image/Logo/TitleBanner2.png" };
const paxg::Texture texture_tl{
#ifdef __ANDROID__
"Logo.png"
#else
path8 + "Image/Logo/TitleBanner2.png"
#endif
};
// 画面サイズを変更
paxg::Window::setSize(
(!texture_tl) ? 700 : texture_tl.width(), (!texture_tl) ? 180 : texture_tl.height());
Expand Down
114 changes: 90 additions & 24 deletions Library/PAX_SAPIENTICA/Siv3D/LocationPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#ifndef PAX_SAPIENTICA_SIV3D_LOCATION_POINT_HPP
#define PAX_SAPIENTICA_SIV3D_LOCATION_POINT_HPP

#ifndef PAXS_PATH
#define PAXS_PATH ""
#endif

#include <string>

#include <PAX_SAPIENTICA/Siv3D/Init.hpp>
Expand All @@ -21,6 +25,7 @@

#include <PAX_GRAPHICA/String.hpp>
#include <PAX_GRAPHICA/Texture.hpp>
#include <PAX_GRAPHICA/Rect.hpp>
#include <PAX_GRAPHICA/Window.hpp>

/*##########################################################################################
Expand Down Expand Up @@ -91,30 +96,43 @@ namespace paxs {
// 古墳を追加(実験用)
void addKofun() {
for (int i = 0; i < 10; ++i)
inputPlace("./../../../../../Data/PlaceName/TestMap/Kofun.tsv", LocationPointEnum::location_point_agent);
inputPlace(std::string("Data/PlaceName/TestMap/Kofun.tsv"), LocationPointEnum::location_point_agent);
}
void add() {
// 古墳
inputPlace("./../../../../../Data/PlaceName/TestMap/Hokkaido.tsv", LocationPointEnum::location_point_zempo_koen_fun);
inputPlace(std::string("Data/PlaceName/TestMap/Hokkaido.tsv"), LocationPointEnum::location_point_zempo_koen_fun);
// 古墳
inputPlace("./../../../../../Data/PlaceName/TestMap/Kofun.tsv", LocationPointEnum::location_point_zempo_koen_fun);
inputPlace(std::string("Data/PlaceName/TestMap/Kofun.tsv"), LocationPointEnum::location_point_zempo_koen_fun);

// 古事記の地名
inputPlace("./../../../../../Data/PlaceName/KojikiPlaceName.tsv");
inputPlace(std::string("Data/PlaceName/KojikiPlaceName.tsv"));
// 汎用的な地名
inputPlace("./../../../../../Data/PlaceName/PlaceName.tsv");
inputPlace(std::string("Data/PlaceName/PlaceName.tsv"));
// 令制国名
inputPlace("./../../../../../Data/PlaceName/Ryoseikoku.tsv");
inputPlace(std::string("Data/PlaceName/Ryoseikoku.tsv"));
// 倭名類聚抄の地名
inputPlace("./../../../../../Data/PlaceName/WamyoRuijushoPlaceName.tsv");
inputPlace(std::string("Data/PlaceName/WamyoRuijushoPlaceName.tsv"));
// 倭名類聚抄の地名
inputPlace("./../../../../../Data/PlaceName/WamyoRuijushoKori.tsv");
inputPlace(std::string("Data/PlaceName/WamyoRuijushoKori.tsv"));
// おもろさうしの地名
inputPlace("./../../../../../Data/PlaceName/OmoroSoshiPlaceName.tsv");
inputPlace(std::string("Data/PlaceName/OmoroSoshiPlaceName.tsv"));
}

PlaceNameLocation() {
}

// アイコンのテクスチャ
texture_ko = paxg::Texture{ PAXS_PATH + std::string("Data/OldDocumentIcon/JP-Kojiki.svg") };
texture_wam = paxg::Texture{ PAXS_PATH + std::string("Data/OldDocumentIcon/JP-WamyoRuijusho.svg") };
texture_pin1 = paxg::Texture{ PAXS_PATH + std::string("Data/Pin/PitDwelling.svg") };
texture_blue_circle = paxg::Texture{ PAXS_PATH + std::string("Data/MiniIcon/BlueCircle.svg") };
texture_red_circle = paxg::Texture{ PAXS_PATH + std::string("Data/MiniIcon/RedCircle.svg") };
texture_kofun1 = paxg::Texture{ PAXS_PATH + std::string("Data/MiniIcon/ZempoKoenFun.png") };
texture_kofun2 = paxg::Texture{PAXS_PATH + std::string("Data/MiniIcon/ZempoKohoFun.png")
};
texture_kofun3 = paxg::Texture{ PAXS_PATH + std::string("Data/MiniIcon/HotategaiGataKofun.png") };
texture_pn = paxg::Texture{ PAXS_PATH + std::string("Data/MiniIcon/PlaceName.svg") };

}
// 描画
void draw(const double jdn,
const double map_view_width, const double map_view_height, const double map_view_center_x, const double map_view_center_y,
Expand Down Expand Up @@ -165,6 +183,16 @@ namespace paxs {
}
// 前方後円墳を描画
if (lli.source == "ZempoKoenFun") {
#ifdef PAXS_USING_DXLIB
paxg::Rect(paxg::Vec2i{
static_cast<int>((lli.coordinate.x - (map_view_center_x - map_view_width / 2)) / map_view_width * double(paxg::Window::width())),
static_cast<int>(double(paxg::Window::height()) - ((lli.coordinate.y - (map_view_center_y - map_view_height / 2)) / map_view_height * double(paxg::Window::height())))
}, paxg::Vec2i{14, 14}).drawAt(paxg::Color{255, 255, 255});
paxg::Rect(paxg::Vec2i{
static_cast<int>((lli.coordinate.x - (map_view_center_x - map_view_width / 2)) / map_view_width * double(paxg::Window::width())),
static_cast<int>(double(paxg::Window::height()) - ((lli.coordinate.y - (map_view_center_y - map_view_height / 2)) / map_view_height * double(paxg::Window::height())))
}, paxg::Vec2i{10, 10}).drawAt(paxg::Color{37, 158, 78});
#endif
texture_kofun1.resizedDrawAt(14,
paxg::Vec2i{
static_cast<int>((lli.coordinate.x - (map_view_center_x - map_view_width / 2)) / map_view_width * double(paxg::Window::width())),
Expand Down Expand Up @@ -246,8 +274,8 @@ namespace paxs {
// 倭名類聚抄のアイコンを描画
else if (lli.source == "JP-WamyoRuijusho") {
//texture_wam.resizedDrawAt(20,
// paxg::Vec2i{ (lli.coordinate.x - (map_view_center_x - map_view_width / 2)) / map_view_width * double(paxg::Window::width()),
// double(paxg::Window::height()) - ((lli.coordinate.y - (map_view_center_y - map_view_height / 2)) / map_view_height * double(paxg::Window::height()))
// paxg::Vec2i{ static_cast<int>((lli.coordinate.x - (map_view_center_x - map_view_width / 2)) / map_view_width * double(paxg::Window::width())),
// static_cast<int>(double(paxg::Window::height()) - ((lli.coordinate.y - (map_view_center_y - map_view_height / 2)) / map_view_height * double(paxg::Window::height())))
// });
}
// 前方後円墳のアイコンを描画
Expand Down Expand Up @@ -302,25 +330,63 @@ namespace paxs {
private:
std::vector<LocationPoint> location_point_list{}; // 地物の一覧
// アイコンのテクスチャ
const paxg::Texture texture_ko{ "./../../../../../Data/OldDocumentIcon/JP-Kojiki.svg" };
const paxg::Texture texture_wam{ "./../../../../../Data/OldDocumentIcon/JP-WamyoRuijusho.svg" };
const paxg::Texture texture_pin1{ "./../../../../../Data/Pin/PitDwelling.svg" };
const paxg::Texture texture_blue_circle{ "./../../../../../Data/MiniIcon/BlueCircle.svg" };
const paxg::Texture texture_red_circle{ "./../../../../../Data/MiniIcon/RedCircle.svg" };
const paxg::Texture texture_kofun1{ "./../../../../../Data/MiniIcon/ZempoKoenFun.svg" };
const paxg::Texture texture_kofun2{ "./../../../../../Data/MiniIcon/ZempoKohoFun.svg" };
const paxg::Texture texture_kofun3{ "./../../../../../Data/MiniIcon/HotategaiGataKofun.svg" };
const paxg::Texture texture_pn{ "./../../../../../Data/MiniIcon/PlaceName.svg" };
paxg::Texture texture_ko{};
paxg::Texture texture_wam{};
paxg::Texture texture_pin1{};
paxg::Texture texture_blue_circle{};
paxg::Texture texture_red_circle{};
paxg::Texture texture_kofun1{};
paxg::Texture texture_kofun2{};
paxg::Texture texture_kofun3{};
paxg::Texture texture_pn{};

// 地名を読み込み
void inputPlace(const std::string& str_, const LocationPointEnum lpe_ = LocationPointEnum::location_point_place_name) {

std::ifstream pifs(str_); // 地名を読み込む
#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_); // 地名を読み込む
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<std::string> 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<std::string> strvec = paxs::StringExtensions::split(pline, '\t');
#endif
// 格納
location_point_list.emplace_back(
strvec[0], // 漢字
Expand All @@ -344,8 +410,8 @@ namespace paxs {
class AgentLocation {
public:
// アイコンのテクスチャ
const paxg::Texture texture_blue_circle{ "./../../../../../Data/MiniIcon/BlueCircle.svg" };
const paxg::Texture texture_red_circle{ "./../../../../../Data/MiniIcon/RedCircle.svg" };
const paxg::Texture texture_blue_circle{ PAXS_PATH + std::string("Data/MiniIcon/BlueCircle.svg") };
const paxg::Texture texture_red_circle{ PAXS_PATH + std::string("Data/MiniIcon/RedCircle.svg") };

void draw(const double jdn,
const std::vector<paxs::Agent<int>>& agents, const paxs::Vector2<int>& start_position,
Expand Down
Loading

0 comments on commit ba93ee7

Please sign in to comment.