自己完結

完全に雑記

その他

12時に起きて、昼飯食って、こたつで寝て15時。

終わっとる。

それはともかく、ようやくNintendoDirectを見た。

3DSの充実っぷりがヤバい。特にXenobladeWiiでやるの面倒だったから嬉しい。ただ、XenobladeXまでの期間が短すぎる上に、世界樹ダンジョンとムジュラ3DSもあって、さらには現在進行中の新世界樹2もある。さらにはイカちゃんもあるし……とにかく、とてもすべてをやり遂げるのは絶対無理だろ!

でもまぁ楽しみが増えてよかったです。(まとめ)

プログラム

VisualStudioのデフォルトのプロジェクト設定ほんと汚い。

プロジェクトファイルと同じ階層にあれこれ適当に作っていくのやめてほしい。

はてさて、今日はとりあえず、テスト周りの整備をした。

BOOST_TEST使おうかと思ったけど、 DxLibで必要なランタイムライブラリ部分の設定が問題で、使用できない事が分かった。

まぁ別にこだわりはないので、VisualStduio付属の子を使ったら行けたのでした。

  1. ソリューションに新しいプロジェクト→テスト→ネイティブ単体テスト プロジェクトを追加
  2. unittest1.cppに適当にテストコードを追加
  3. テストコードに必要なファイルをinclude
  4. includeしたヘッダの実装をリンクするため以下の設定を行う
    1. 構成プロパティ→リンカー→入力→追加の依存ファイル3で必要なobjなりlibを追加( path.obj とか、パスではなくてobjの名前だけで良い )
    2. 構成プロパティ→リンカー→入力→全般→追加のライブラリディレクトリ4.1で追加したファイルがあるパスを追加

って感じだったような。 DxLib使ってるんだったら、構成プロパティ→コード生成→ランタイムライブラリを、DxLibの設定と同じ形に変更しなきゃいけません。

は~あ。

とまぁ、これでテストができるようになったし、捗ってくれるはずだよね。

次はjenkinsにテスト実行してもらうようにしないとダメだけど、まぁこれは追々な。

プログラム 追記

configが反映されない問題

どうもファイルを開けていなかったらしい。
原因はコンフィグファイルの先頭に謎の文字情報が入っていたからなようだ。

オープンしようとして死んでいた。 gitからcloneした時に紛れ込んだのだろうか…わからん。

ということでいくらかコードをリメイクした。

path.h

#include <boost/filesystem.hpp>

namespace gfw{
namespace path{

    /** 実行ファイルのパスを取得する **/
    const boost::filesystem::path GetExecuteFilePath();

    /** 設定用ディレクトリのパスを取得 **/
    const boost::filesystem::path GetSettingDirPath();

    /** 設定ファイルのパスを取得する **/
    const boost::filesystem::path GetSettingFilePath();

    /** スクリプトのディレクトリパスを取得 **/
    const boost::filesystem::path GetScriptDirPath();

}
}

path.cpp

const boost::filesystem::path gfw::path::GetExecuteFilePath() {
    HMODULE hModule = GetModuleHandleW(NULL);
    WCHAR path[MAX_PATH];
    GetModuleFileNameW(hModule, path, MAX_PATH);

    boost::filesystem::path executePath(path);
    return executePath;
}

const boost::filesystem::path gfw::path::GetSettingDirPath() {
    return gfw::path::GetExecuteFilePath().parent_path() / "config";
}

const boost::filesystem::path gfw::path::GetSettingFilePath() {
    return gfw::path::GetExecuteFilePath().parent_path() / "config" / "setting.ini";
}

const boost::filesystem::path gfw::path::GetScriptDirPath() {
    return gfw::path::GetExecuteFilePath().parent_path() / "script";
}

main.h

/**  セッティング情報を読み込みます。 **/
boost::optional< initcode::SGameSetting > LoadSettingParams(const std::string& settingIniFile);

main.cpp

boost::optional< initcode::SGameSetting > LoadSettingParams( const std::string& settingIniFile ) {

    //データを読み込んでゲーム画面の設定をします
    ptree iniFIleTree;

    // iniファイルを読んで設定
    try {
        read_ini(settingIniFile, iniFIleTree);
    } catch( std::exception& ex) {
        return boost::optional<initcode::SGameSetting>( boost::none );
    }

    initcode::SGameSetting set;

    if (boost::optional<int> wtype = iniFIleTree.get_optional<int>("CONFIG.wsize"))
        set.wintype = *wtype;

    if (boost::optional<int> vsync = iniFIleTree.get_optional<int>("CONFIG.vsync"))
        set.vsync = *vsync;

    if (boost::optional<int> dtype = iniFIleTree.get_optional<int>("CONFIG.type"))
        set.drawtype = *dtype;

    if (boost::optional<int> dtype = iniFIleTree.get_optional<int>("CONFIG.ex_back"))
        set.ex_background = *dtype;

    return boost::optional<initcode::SGameSetting>( set );
}