機能
棒グラフ用構造体です。
変数
private: int m_nSP; int m_nMin; int m_nMax; int m_nValue; sact_bar_graph_metrics_t m_sbgm;
メソッド
機能:初期化
nSP=0の場合空きSP番号を自動で取得
位置設定、表示on/offなどは直接SP_SET_POS()などで行う
使用スプライト番号を返す
int sact_bar_graph_t::Init(int nSP, ref sact_bar_graph_metrics_t sbgm) { if(nSP == 0) { nSP = SP_GET_UNUSE_NUM(); } m_nSP = nSP; m_sbgm = sbgm; SP_CREATE(m_nSP, m_sbgm.nWidth, m_sbgm.nHeight, m_sbgm.nBackColorR, m_sbgm.nBackColorG, m_sbgm.nBackColorB, m_sbgm.nBackBlend); return m_nSP; }
機能:使用スプライト番号取得
int sact_bar_graph_t::GetSpriteNum(void) { return m_nSP; }
機能: 値の幅設定
表示中の棒グラフは SetValue まで変更されない
void sact_bar_graph_t::SetRange(int nMin, int nMax) { m_nMin = nMin; m_nMax = nMax; }
機能:値設定 bUpdate=true で SACT_UPDATE() が呼ばれる(デフォルト=false)
void sact_bar_graph_t::SetValue(int nValue, int bUpdate) { m_nValue = nValue; // 背景塗りつぶし CG_FILL(m_nSP, 0, 0, m_sbgm.nWidth, m_sbgm.nHeight, m_sbgm.nBackColorR, m_sbgm.nBackColorG, m_sbgm.nBackColorB); CG_FILL_AMAP(m_nSP, 0, 0, m_sbgm.nWidth, m_sbgm.nHeight, m_sbgm.nBackBlend); // 棒 switch(m_sbgm.nType) { case SBGMT_LR:/* → */SetBarValueLR(); break; case SBGMT_RL:/* ← */SetBarValueRL(); break; case SBGMT_TB:/* ↓ */SetBarValueTB(); break; case SBGMT_BT:/* ↑ */SetBarValueBT(); break; default: system.Error("sact_bar_graph_t\n未対応のタイプ"); break; } if(bUpdate) { SACT_UPDATE(); } }
機能:
void sact_bar_graph_t::SetBarValueLR(void) { int a = m_sbgm.nWidth; int b = m_nValue; int c = m_nMax - m_nMin; int d = a * b / c; int x = 0; int y = 0; int w = d; int h = m_sbgm.nHeight; if(d > 0) { CG_FILL(m_nSP, x, y, w, h, m_sbgm.nBarColorR, m_sbgm.nBarColorG, m_sbgm.nBarColorB); CG_FILL_AMAP(m_nSP, x, y, w, h, m_sbgm.nBarBlend); } }
機能:
void sact_bar_graph_t::SetBarValueRL(void) { int a = m_sbgm.nWidth; int b = m_nValue; int c = m_nMax - m_nMin; int d = a * b / c; int x = m_sbgm.nWidth - d; int y = 0; int w = d; int h = m_sbgm.nHeight; if(d > 0) { CG_FILL(m_nSP, x, y, w, h, m_sbgm.nBarColorR, m_sbgm.nBarColorG, m_sbgm.nBarColorB); CG_FILL_AMAP(m_nSP, x, y, w, h, m_sbgm.nBarBlend); } }
機能:
void sact_bar_graph_t::SetBarValueTB(void) { int a = m_sbgm.nHeight; int b = m_nValue; int c = m_nMax - m_nMin; int d = a * b / c; int x = 0; int y = 0; int w = m_sbgm.nWidth; int h = d; if(d > 0) { CG_FILL(m_nSP, x, y, w, h, m_sbgm.nBarColorR, m_sbgm.nBarColorG, m_sbgm.nBarColorB); CG_FILL_AMAP(m_nSP, x, y, w, h, m_sbgm.nBarBlend); } }
機能:
void sact_bar_graph_t::SetBarValueBT(void) { int a = m_sbgm.nHeight; int b = m_nValue; int c = m_nMax - m_nMin; int d = a * b / c; int x = 0; int y = m_sbgm.nHeight - d; int w = m_sbgm.nWidth; int h = d; if(d > 0) { CG_FILL(m_nSP, x, y, w, h, m_sbgm.nBarColorR, m_sbgm.nBarColorG, m_sbgm.nBarColorB); CG_FILL_AMAP(m_nSP, x, y, w, h, m_sbgm.nBarBlend); } }
コンストラクタ
sact_bar_graph_t();
sact_bar_graph_t::sact_bar_graph_t() {//初期値設定 m_nSP = 0; //スプライト番号0 m_nMin = 0; // m_nMax = 100; // m_nValue = 0; }
デストラクタ
sact_bar_graph_t();//破棄時にスプライトは自動的に削除される
sact_bar_graph_t::~sact_bar_graph_t() { SP_DEL(m_nSP); }
グローバル宣言
なし