--- nono/lib/monitor.h 2026/04/29 17:04:54 1.1 +++ nono/lib/monitor.h 2026/04/29 17:05:12 1.1.1.3 @@ -4,12 +4,16 @@ // Licensed under nono-license.txt // +// +// モニタ管理 +// + #pragma once #include "geometric.h" +#include "mainapp.h" #include "object.h" #include "textscreen.h" -#include "vm.h" // モニタ識別子 // @@ -40,6 +44,8 @@ static constexpr bool IS_MONITOR_MEMDUMP class Monitor; using MonitorCallback_t = void (Object::*)(Monitor *, TextScreen&); +#define ToMonitorCallback(f) static_cast(f) + // モニタコールバックを宣言するマクロ。 // 強制力はないけどヘッダで宣言するところで使うこと。 // コールバック関数の型が変わった時にコンパイルエラーで検出させるため。 @@ -60,10 +66,15 @@ class Monitor int GetId() const { return id; } + // モニターの表示サイズを設定・取得。 void SetSize(nnSize size_) { size = size_; } void SetSize(int col_, int row_) { SetSize(nnSize(col_, row_)); } virtual nnSize GetSize() const { return size; } + // モニターが縦に可変長の場合の最大表示行数。(固定長なら 0) + void SetMaxHeight(int maxh_) { maxh = maxh_; } + int GetMaxHeight() const { return maxh; } + // 登録。 // モニタの登録はコンストラクタおよび Create フェーズまでに行うこと。 // Create() の後、Init() より前に -M オプションの処理があるため。 @@ -79,6 +90,9 @@ class Monitor // モニターサイズ nnSize size {}; + + // 縦に可変長の場合の最大表示行数 (固定長なら 0) + int maxh {}; }; // @@ -91,11 +105,14 @@ class MonitorManager // モニター情報 (事前定義) struct MonitorInfo { int id; - vmf_t feature; + VMCap vmcap; std::vector aliases; }; public: + MonitorManager(); + ~MonitorManager(); + // 現在登録されているモニターのリストを返す。 const std::vector& GetList() const { return list; } @@ -107,7 +124,7 @@ class MonitorManager return *mon; } } - assertmsg(false, "id=%d not found", id); + PANIC("id=%d not found", id); } // 指定された id を持つモニターを返す。 @@ -121,10 +138,10 @@ class MonitorManager return NULL; } - // 指定された id に対応する機種フラグを返す。 - vmf_t GetFeature(int id) const { + // 指定された id に対応する機種ケーパビリティを返す。 + VMCap GetVMCap(int id) const { assert(0 <= id && id < info.size()); - return info[id].feature; + return info[id].vmcap; } // 指定された id に対応する名前のリストを返す。 @@ -157,4 +174,4 @@ class MonitorManager bool fixed {}; }; -extern MonitorManager gMonitorManager; +extern MonitorManager *gMonitorManager;