• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。


Commit MetaInfo

Revision232 (tree)
Time2020-01-21 00:17:15
Authorxops-mikan

Log Message

メニュー画面のスクロールバー処理をクラス化、ポイント読み込み時の処理を改善

Change Summary

Incremental Difference

--- trunk/datafile.cpp (revision 231)
+++ trunk/datafile.cpp (revision 232)
@@ -415,8 +415,8 @@
415415 {
416416 FILE *fp;
417417 unsigned char pdata_header[2];
418- float pdata_mainf[MAX_POINTS][4];
419- char pdata_mainc[MAX_POINTS][4];
418+ float pdata_mainf[4];
419+ char pdata_mainc[4];
420420 char fname2[MAX_PATH];
421421
422422 #ifdef ENABLE_DEBUGLOG
@@ -448,18 +448,18 @@
448448 data[i].id = i;
449449
450450 //座標データ取得
451- fread( pdata_mainf[i], 4, 4, fp );
452- data[i].x = pdata_mainf[i][0];
453- data[i].y = pdata_mainf[i][1];
454- data[i].z = pdata_mainf[i][2];
455- data[i].r = pdata_mainf[i][3];
451+ fread( pdata_mainf, 4, 4, fp );
452+ data[i].x = pdata_mainf[0];
453+ data[i].y = pdata_mainf[1];
454+ data[i].z = pdata_mainf[2];
455+ data[i].r = pdata_mainf[3];
456456
457457 //パラメータ取得
458- fread( pdata_mainc[i], 1, 4, fp );
459- data[i].p1 = pdata_mainc[i][0];
460- data[i].p2 = pdata_mainc[i][1];
461- data[i].p3 = pdata_mainc[i][2];
462- data[i].p4 = pdata_mainc[i][3];
458+ fread( pdata_mainc, 1, 4, fp );
459+ data[i].p1 = pdata_mainc[0];
460+ data[i].p2 = pdata_mainc[1];
461+ data[i].p3 = pdata_mainc[2];
462+ data[i].p4 = pdata_mainc[3];
463463 }
464464
465465 //ファイルポインタを閉じる
--- trunk/gamemain.cpp (revision 231)
+++ trunk/gamemain.cpp (revision 232)
@@ -453,8 +453,6 @@
453453 mainmenu::mainmenu()
454454 {
455455 demopath[0] = '\0';
456- mainmenu_scrollitems_official = 0;
457- mainmenu_scrollitems_addon = 0;
458456 }
459457
460458 //! @brief ディストラクタ
@@ -532,34 +530,16 @@
532530
533531 mainmenu_mouseX = SCREEN_WIDTH/2;
534532 mainmenu_mouseY = SCREEN_HEIGHT/2;
533+ mainmenu_mouseY_old = mainmenu_mouseY;
535534
536- //標準ミッションのスクロールバーの設定
537-#if TOTAL_OFFICIALMISSION > TOTAL_MENUITEMS
538- //if( TOTAL_OFFICIALMISSION > TOTAL_MENUITEMS ){
539- mainmenu_scrollbar_official_height = (float)(MAINMENU_H-25) / TOTAL_OFFICIALMISSION * TOTAL_MENUITEMS;
540- mainmenu_scrollbar_official_scale = ((float)(MAINMENU_H-25) - mainmenu_scrollbar_official_height) / (TOTAL_OFFICIALMISSION - TOTAL_MENUITEMS);
541- //}
542-#else
543- //else{
544- mainmenu_scrollbar_official_height = 0.0f;
545- mainmenu_scrollbar_official_scale = 0.0f;
546- //}
547-#endif
535+ //ミッションのスクロールバーの設定
536+ scrollbar_official.Create(MAINMENU_X+341, MAINMENU_Y+1, 19, MAINMENU_H-1-24, TOTAL_OFFICIALMISSION, TOTAL_MENUITEMS, scrollbar_official.GetScrollItem());
537+ scrollbar_official.SetColor(d3dg->GetColorCode(0.5f,0.5f,0.5f,0.5f), d3dg->GetColorCode(0.6f,0.6f,0.25f,1.0f), d3dg->GetColorCode(0.8f,0.8f,0.25f,1.0f),
538+ d3dg->GetColorCode(0.4f,0.67f,0.57f,1.0f), d3dg->GetColorCode(0.38f,0.77f,0.64f,1.0f), d3dg->GetColorCode(0.6f,0.3f,0.25f,1.0f), d3dg->GetColorCode(0.8f,0.3f,0.25f,1.0f));
539+ scrollbar_addon.Create(MAINMENU_X+341, MAINMENU_Y+1, 19, MAINMENU_H-1-24, GameAddon.GetTotaldatas(), TOTAL_MENUITEMS, scrollbar_addon.GetScrollItem());
540+ scrollbar_addon.SetColor(d3dg->GetColorCode(0.5f,0.5f,0.5f,0.5f), d3dg->GetColorCode(0.6f,0.6f,0.25f,1.0f), d3dg->GetColorCode(0.8f,0.8f,0.25f,1.0f),
541+ d3dg->GetColorCode(0.4f,0.67f,0.57f,1.0f), d3dg->GetColorCode(0.38f,0.77f,0.64f,1.0f), d3dg->GetColorCode(0.6f,0.3f,0.25f,1.0f), d3dg->GetColorCode(0.8f,0.3f,0.25f,1.0f));
548542
549- //addonのスクロールバーの設定
550- if( GameAddon.GetTotaldatas() > TOTAL_MENUITEMS ){
551- mainmenu_scrollbar_addon_height = (float)(MAINMENU_H-25) / GameAddon.GetTotaldatas() * TOTAL_MENUITEMS;
552- mainmenu_scrollbar_addon_scale = ((float)(MAINMENU_H-25) - mainmenu_scrollbar_addon_height) / (GameAddon.GetTotaldatas() - TOTAL_MENUITEMS);
553- }
554- else{
555- mainmenu_scrollbar_addon_height = 0.0f;
556- mainmenu_scrollbar_addon_scale = 0.0f;
557- }
558-
559- mainmenu_scrollbar_official_y = MAINMENU_Y+1 + (int)(mainmenu_scrollbar_official_scale*mainmenu_scrollitems_official);
560- mainmenu_scrollbar_addon_y = MAINMENU_Y+1 + (int)(mainmenu_scrollbar_addon_scale*mainmenu_scrollitems_addon);
561- mainmenu_scrollbar_flag = false;
562-
563543 #ifdef ENABLE_MENUOPTIONS
564544 CreateOptions();
565545 #endif
@@ -589,7 +569,6 @@
589569 inputCtrl->GetInputState(false);
590570
591571 //マウス座標を取得
592- int y = mainmenu_mouseY;
593572 inputCtrl->GetMouseMovement(&mainmenu_mouseX, &mainmenu_mouseY);
594573 if( mainmenu_mouseX < 0 ){ mainmenu_mouseX = 0; }
595574 if( mainmenu_mouseX > SCREEN_WIDTH-1 ){ mainmenu_mouseX = SCREEN_WIDTH-1; }
@@ -597,31 +576,22 @@
597576 if( mainmenu_mouseY > SCREEN_HEIGHT-1 ){ mainmenu_mouseY = SCREEN_HEIGHT-1; }
598577
599578 if( modescreen == 0 ){
600- //スクロールバーの情報などを取得
579+ //スクロールバーを処理し情報取得
601580 int scrollitems;
602- float scrollbar_height;
603- float scrollbar_scale;
604- int scrollbar_y;
605581 int totalmission;
606582 if( GameInfoData.selectaddon == false ){
607- scrollitems = mainmenu_scrollitems_official;
608- scrollbar_height = mainmenu_scrollbar_official_height;
609- scrollbar_scale = mainmenu_scrollbar_official_scale;
610- scrollbar_y = mainmenu_scrollbar_official_y;
583+ scrollbar_official.Input(mainmenu_mouseX, mainmenu_mouseY, inputCtrl->CheckMouseButtonNowL(), mainmenu_mouseY - mainmenu_mouseY_old);
584+ scrollitems = scrollbar_official.GetScrollItem();
611585 totalmission = TOTAL_OFFICIALMISSION;
612586 }
613587 else{
614- scrollitems = mainmenu_scrollitems_addon;
615- scrollbar_height = mainmenu_scrollbar_addon_height;
616- scrollbar_scale = mainmenu_scrollbar_addon_scale;
617- scrollbar_y = mainmenu_scrollbar_addon_y;
588+ scrollbar_addon.Input(mainmenu_mouseX, mainmenu_mouseY, inputCtrl->CheckMouseButtonNowL(), mainmenu_mouseY - mainmenu_mouseY_old);
589+ scrollitems = scrollbar_addon.GetScrollItem();
618590 totalmission = GameAddon.GetTotaldatas();
619591 }
620592
621- if( inputCtrl->CheckKeyDown(GetEscKeycode()) ){ //ESCキーを処理
622- GameState->PushBackSpaceKey();
623- }
624- else if( inputCtrl->CheckMouseButtonUpL() ){ //ミッション選択
593+ //ミッション選択
594+ if( inputCtrl->CheckMouseButtonUpL() ){
625595 for(int i=0; i<TOTAL_MENUITEMS; i++){
626596 char name[32];
627597 strcpy(name, "");
@@ -639,57 +609,28 @@
639609 }
640610 }
641611
642- //スクロールバーを押したか判定
643- if( inputCtrl->CheckMouseButtonDownL() ){
644- if( ((MAINMENU_X+341) < mainmenu_mouseX)&&(mainmenu_mouseX < (MAINMENU_X+360))&&(MAINMENU_Y+1 + (int)(scrollbar_scale*scrollitems) < mainmenu_mouseY)
645- &&(mainmenu_mouseY < MAINMENU_Y+1 + (int)(scrollbar_scale*scrollitems + scrollbar_height))
646- ){
647- mainmenu_scrollbar_flag = true;
648- }
649- }
650-
651612 if( inputCtrl->CheckMouseButtonUpL() ){
652- mainmenu_scrollbar_flag = false;
653-
654613 // UP
655614 if( (MAINMENU_X < mainmenu_mouseX)&&(mainmenu_mouseX < (MAINMENU_X+340))&&(MAINMENU_Y < mainmenu_mouseY)&&(mainmenu_mouseY < MAINMENU_Y+30) ){
656- if( scrollitems > 0 ){ scrollitems -= 1; }
615+ if( GameInfoData.selectaddon == false ){
616+ scrollbar_official.ScrollUP();
617+ }
618+ else{
619+ scrollbar_addon.ScrollUP();
620+ }
657621 }
658622
659623 // DOWN
660624 if( (MAINMENU_X < mainmenu_mouseX)&&(mainmenu_mouseX < (MAINMENU_X+340))&&((MAINMENU_Y+MAINMENU_H-55) < mainmenu_mouseY)&&(mainmenu_mouseY < (MAINMENU_Y+MAINMENU_H-55+30)) ){
661- if( scrollitems < (totalmission - TOTAL_MENUITEMS) ){ scrollitems += 1; }
625+ if( GameInfoData.selectaddon == false ){
626+ scrollbar_official.ScrollDOWN();
627+ }
628+ else{
629+ scrollbar_addon.ScrollDOWN();
630+ }
662631 }
663632 }
664633
665- //スクロールバーの移動
666- if( mainmenu_scrollbar_flag == true ){
667- scrollbar_y += mainmenu_mouseY - y;
668- if( scrollbar_y < MAINMENU_Y+1 ){ scrollbar_y = MAINMENU_Y+1; }
669- if( scrollbar_y > MAINMENU_Y+MAINMENU_H-24 - (int)(scrollbar_height) ){ scrollbar_y = MAINMENU_Y+MAINMENU_H-24 - (int)(scrollbar_height); }
670-
671- scrollitems = (scrollbar_y - (MAINMENU_Y+1)) / (int)(scrollbar_scale);
672- if( scrollitems < 0 ){
673- scrollitems = 0;
674- }
675- if( scrollitems > (totalmission - TOTAL_MENUITEMS) ){
676- scrollitems = (totalmission - TOTAL_MENUITEMS);
677- }
678- }
679- else{
680- scrollbar_y = MAINMENU_Y+1 + (int)(scrollbar_scale*scrollitems);
681- }
682-
683- //スクロールバーの情報などを反映
684- if( GameInfoData.selectaddon == false ){
685- mainmenu_scrollitems_official = scrollitems;
686- mainmenu_scrollbar_official_y = scrollbar_y;
687- }
688- else{
689- mainmenu_scrollitems_addon = scrollitems;
690- mainmenu_scrollbar_addon_y = scrollbar_y;
691- }
692-
693634 //標準ミッションとアドオンリストの切り替え
694635 if( inputCtrl->CheckMouseButtonUpL() ){
695636 if( (MAINMENU_X < mainmenu_mouseX)&&(mainmenu_mouseX < (MAINMENU_X+340))&&((MAINMENU_Y+MAINMENU_H-25) < mainmenu_mouseY)&&(mainmenu_mouseY < (MAINMENU_Y+MAINMENU_H-2)) ){
@@ -712,6 +653,11 @@
712653 }
713654 }
714655 #endif
656+
657+ //ESCキーを処理
658+ if( inputCtrl->CheckKeyDown(GetEscKeycode()) ){
659+ GameState->PushBackSpaceKey();
660+ }
715661 }
716662 else{
717663 #ifdef ENABLE_MENUOPTIONS
@@ -718,6 +664,8 @@
718664 InputOptions();
719665 #endif
720666 }
667+
668+ mainmenu_mouseY_old = mainmenu_mouseY;
721669 }
722670
723671 void mainmenu::Process()
@@ -767,7 +715,7 @@
767715
768716 void mainmenu::Render2D()
769717 {
770- int color, color2;
718+ int color;
771719 float effect;
772720
773721 //ゲームのバージョン情報表示
@@ -775,21 +723,15 @@
775723 d3dg->Draw2DTextureFontText(522, 75, GAMEVERSION, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 18, 22);
776724
777725 if( modescreen == 0 ){
778- //スクロールバーの情報などを取得
726+ //スクロールバーの情報を取得
779727 int scrollitems;
780- float scrollbar_height;
781- int scrollbar_y;
782728 int totalmission;
783729 if( GameInfoData.selectaddon == false ){
784- scrollitems = mainmenu_scrollitems_official;
785- scrollbar_height = mainmenu_scrollbar_official_height;
786- scrollbar_y = mainmenu_scrollbar_official_y;
730+ scrollitems = scrollbar_official.GetScrollItem();
787731 totalmission = TOTAL_OFFICIALMISSION;
788732 }
789733 else{
790- scrollitems = mainmenu_scrollitems_addon;
791- scrollbar_height = mainmenu_scrollbar_addon_height;
792- scrollbar_y = mainmenu_scrollbar_addon_y;
734+ scrollitems = scrollbar_addon.GetScrollItem();
793735 totalmission = GameAddon.GetTotaldatas();
794736 }
795737
@@ -800,28 +742,14 @@
800742 else{
801743 d3dg->Draw2DBox(MAINMENU_X-1, MAINMENU_Y, MAINMENU_X+360, MAINMENU_Y+MAINMENU_H-24, d3dg->GetColorCode(0.0f,0.0f,0.0f,0.5f));
802744 }
803- d3dg->Draw2DBox(MAINMENU_X+341, MAINMENU_Y+1, MAINMENU_X+360, MAINMENU_Y+MAINMENU_H-24, d3dg->GetColorCode(0.5f,0.5f,0.5f,0.5f));
804745
805746 //スクロールバー描画
806- if( totalmission > TOTAL_MENUITEMS ){
807- //色を設定
808- if( mainmenu_scrollbar_flag == true ){
809- color = d3dg->GetColorCode(0.6f,0.3f,0.25f,1.0f);
810- color2 = d3dg->GetColorCode(0.8f,0.3f,0.25f,1.0f);
811- }
812- else if( ((MAINMENU_X+341) < mainmenu_mouseX)&&(mainmenu_mouseX < (MAINMENU_X+360))&&(scrollbar_y < mainmenu_mouseY)&&(mainmenu_mouseY < scrollbar_y + (int)scrollbar_height) ){
813- color = d3dg->GetColorCode(0.4f,0.67f,0.57f,1.0f);
814- color2 = d3dg->GetColorCode(0.38f,0.77f,0.64f,1.0f);
815- }
816- else{
817- color = d3dg->GetColorCode(0.6f,0.6f,0.25f,1.0f);
818- color2 = d3dg->GetColorCode(0.8f,0.8f,0.25f,1.0f);
819- }
820-
821- //描画
822- d3dg->Draw2DBox(MAINMENU_X+341, scrollbar_y, MAINMENU_X+360, scrollbar_y + (int)scrollbar_height, color);
823- d3dg->Draw2DBox(MAINMENU_X+341+3, scrollbar_y +3, MAINMENU_X+360-3, scrollbar_y + (int)scrollbar_height -3, color2);
747+ if( GameInfoData.selectaddon == false ){
748+ scrollbar_official.Draw(d3dg);
824749 }
750+ else{
751+ scrollbar_addon.Draw(d3dg);
752+ }
825753
826754 //'< UP >'表示
827755 if( scrollitems > 0 ){
--- trunk/gamemain.h (revision 231)
+++ trunk/gamemain.h (revision 232)
@@ -155,15 +155,9 @@
155155 int modescreen; //!< 表示画面
156156 int mainmenu_mouseX; //!< メニュー画面マウスX座標
157157 int mainmenu_mouseY; //!< メニュー画面マウスY座標
158- int mainmenu_scrollitems_official; //!< メニュー画面のスクロールしたアイテム数
159- int mainmenu_scrollitems_addon; //!< メニュー画面のスクロールしたアイテム数
160- float mainmenu_scrollbar_official_height; //!< メニュー画面のスクロールバーの高さ
161- float mainmenu_scrollbar_official_scale; //!< メニュー画面のスクロールバーの目盛
162- int mainmenu_scrollbar_official_y; //!< メニュー画面のスクロールバーのY座標
163- float mainmenu_scrollbar_addon_height; //!< メニュー画面のスクロールバーの高さ
164- float mainmenu_scrollbar_addon_scale; //!< メニュー画面のスクロールバーの目盛
165- int mainmenu_scrollbar_addon_y; //!< メニュー画面のスクロールバーのY座標
166- bool mainmenu_scrollbar_flag; //!< メニュー画面のスクロールバーを操作中を示すフラグ
158+ int mainmenu_mouseY_old; //!< メニュー画面マウスY座標(前回のフレーム)
159+ class ScrollbarObject scrollbar_official; //!< 標準ミッションのスクロールバー
160+ class ScrollbarObject scrollbar_addon; //!< addonのスクロールバー
167161 int gametitle; //!< ゲームタイトル画像
168162 #ifdef ENABLE_MENUOPTIONS
169163 MenuLinkTextData Options_p1LinkTextData[OPTIONS_P1_DATAS]; //!< オプション画面 No.1 リンクテキストデータ
--- trunk/gui-object.cpp (nonexistent)
+++ trunk/gui-object.cpp (revision 232)
@@ -0,0 +1,213 @@
1+//! @file gui-object.cpp
2+//! @brief gui-object関連クラスの定義
3+
4+//--------------------------------------------------------------------------------
5+//
6+// OpenXOPS
7+// Copyright (c) 2014-2020, OpenXOPS Project / [-_-;](mikan) All rights reserved.
8+//
9+// Redistribution and use in source and binary forms, with or without
10+// modification, are permitted provided that the following conditions are met:
11+// * Redistributions of source code must retain the above copyright notice,
12+// this list of conditions and the following disclaimer.
13+// * Redistributions in binary form must reproduce the above copyright notice,
14+// this list of conditions and the following disclaimer in the documentation
15+// and/or other materials provided with the distribution.
16+// * Neither the name of the OpenXOPS Project nor the names of its contributors
17+// may be used to endorse or promote products derived from this software
18+// without specific prior written permission.
19+//
20+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+// DISCLAIMED. IN NO EVENT SHALL OpenXOPS Project BE LIABLE FOR ANY
24+// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+//--------------------------------------------------------------------------------
31+
32+#include "gui-object.h"
33+
34+//! @brief コンストラクタ
35+ScrollbarObject::ScrollbarObject()
36+{
37+ pos_x = 0;
38+ pos_y = 0;
39+ width = 0;
40+ height = 0;
41+ totalitems = 0;
42+ showtems = 0;
43+ scrollitem = 0;
44+ knob_height = 0.0f;
45+ knob_scale = 0.0f;
46+ knob_y = 0;
47+ mouse_mode = 0;
48+ color_body = 0x00000000;
49+ color1_default = 0x00000000;
50+ color2_default = 0x00000000;
51+ color1_cursor = 0x00000000;
52+ color2_cursor = 0x00000000;
53+ color1_select = 0x00000000;
54+ color2_select = 0x00000000;
55+}
56+
57+//! @brief ディストラクタ
58+ScrollbarObject::~ScrollbarObject()
59+{
60+ //
61+}
62+
63+//! @brief スクロールバー初期化
64+//! @param x x座標
65+//! @param y y座標
66+//! @param w 幅
67+//! @param h 高さ
68+//! @param in_totalitems 総アイテム数
69+//! @param in_showtems 画面に表示するアイテム数
70+//! @param in_scrollitem スクロールしたアイテム数
71+//! @warning サイズは幅・高さそれぞれ 8以上 に設定してください。
72+//! @attention SetColor()関数でスクロールバーの色を設定してください。
73+void ScrollbarObject::Create(int x, int y, int w, int h, int in_totalitems, int in_showtems, int in_scrollitem)
74+{
75+ pos_x = x;
76+ pos_y = y;
77+ width = w;
78+ height = h;
79+ totalitems = in_totalitems;
80+ showtems = in_showtems;
81+ scrollitem = in_scrollitem;
82+ knob_height = (float)h / totalitems * showtems;
83+ knob_scale = ((float)h - knob_height) / (totalitems - showtems);
84+ knob_y = (int)(knob_scale * scrollitem);
85+ mouse_mode = 0;
86+}
87+
88+//! @brief スクロールバーの色を設定
89+//! @param body 本体(後ろ側)の色
90+//! @param default1 通常時のつまみの色(外側)
91+//! @param default2 通常時のつまみの色(内側)
92+//! @param cursor1 カーソル選択時のつまみの色(外側)
93+//! @param cursor2 カーソル選択時のつまみの色(内側)
94+//! @param select1 クリック時のつまみの色(外側)
95+//! @param select2 クリック時のつまみの色(内側)
96+void ScrollbarObject::SetColor(int body, int default1, int default2, int cursor1, int cursor2, int select1, int select2)
97+{
98+ color_body = body;
99+ color1_default = default1;
100+ color2_default = default2;
101+ color1_cursor = cursor1;
102+ color2_cursor = cursor2;
103+ color1_select = select1;
104+ color2_select = select2;
105+}
106+
107+//! @brief スクロールしたアイテム数設定
108+//! @param id アイテム数
109+void ScrollbarObject::SetScrollItem(int id)
110+{
111+ if( (id < 0)||(id <= totalitems) ){ return; }
112+
113+ scrollitem = id;
114+}
115+
116+//! @brief スクロールしたアイテム数取得
117+//! @return アイテム数
118+int ScrollbarObject::GetScrollItem()
119+{
120+ return scrollitem;
121+}
122+
123+//! @brief 上方向へスクロール
124+void ScrollbarObject::ScrollUP()
125+{
126+ if( scrollitem > 0 ){
127+ scrollitem -= 1;
128+ }
129+}
130+
131+//! @brief 下方向へスクロール
132+void ScrollbarObject::ScrollDOWN()
133+{
134+ if( scrollitem < (totalitems - showtems) ){
135+ scrollitem += 1;
136+ }
137+}
138+
139+//! @brief スクロールバー入力処理
140+//! @param mouse_x マウスx座標
141+//! @param mouse_y マウスy座標
142+//! @param mouse_click マウスクリックフラグ
143+//! @param scroll_y y方向のスクロール量
144+void ScrollbarObject::Input(int mouse_x, int mouse_y, bool mouse_click, int scroll_y)
145+{
146+ //スクロールバーの操作判定
147+ if( mouse_mode == 2 ){
148+ if( mouse_click == false ){
149+ mouse_mode = 0; //or 1
150+ }
151+ }
152+ if( mouse_mode != 2 ){
153+ if( (pos_x < mouse_x)&&(mouse_x < (pos_x+width))
154+ &&(pos_y + (int)(knob_scale * scrollitem) < mouse_y)&&(mouse_y < pos_y + (int)(knob_scale * scrollitem + knob_height))
155+ ){
156+ if( mouse_click == true ){
157+ mouse_mode = 2;
158+ }
159+ else{
160+ mouse_mode = 1;
161+ }
162+ }
163+ else{
164+ mouse_mode = 0;
165+ }
166+ }
167+
168+ //スクロールバーの移動
169+ if( mouse_mode == 2 ){
170+ knob_y += scroll_y;
171+ if( knob_y < 0 ){ knob_y = 0; }
172+ if( knob_y > (height - (int)knob_height) ){ knob_y = (height - (int)knob_height); }
173+
174+ scrollitem = (int)((float)knob_y / knob_scale);
175+ if( scrollitem < 0 ){ scrollitem = 0; }
176+ if( scrollitem > (totalitems - showtems) ){ scrollitem = (totalitems - showtems); }
177+ }
178+ else{
179+ knob_y = (int)(knob_scale * scrollitem);
180+ }
181+}
182+
183+//! @brief スクロールバー描画処理
184+//! @param d3dg D3DGraphicsのポインタ
185+//! @attention 「合計アイテム数<表示するアイテム数」の場合、ノブは表示されません。
186+void ScrollbarObject::Draw(class D3DGraphics *d3dg)
187+{
188+ int color, color2;
189+
190+ //エリア描画
191+ d3dg->Draw2DBox(pos_x, pos_y, pos_x+width, pos_y+height, color_body);
192+
193+ //ノブ描画
194+ if( totalitems > showtems ){
195+ //色を設定
196+ if( mouse_mode == 2 ){
197+ color = color1_select;
198+ color2 = color2_select;
199+ }
200+ else if( mouse_mode == 1 ){
201+ color = color1_cursor;
202+ color2 = color2_cursor;
203+ }
204+ else{
205+ color = color1_default;
206+ color2 = color2_default;
207+ }
208+
209+ //描画
210+ d3dg->Draw2DBox(pos_x, pos_y+knob_y, pos_x+width, pos_y+knob_y + (int)knob_height, color);
211+ d3dg->Draw2DBox(pos_x+3, pos_y+knob_y+3, pos_x+width-3, pos_y+knob_y + (int)knob_height -3, color2);
212+ }
213+}
--- trunk/gui-object.h (nonexistent)
+++ trunk/gui-object.h (revision 232)
@@ -0,0 +1,77 @@
1+//! @file gui-object.h
2+//! @brief gui-object関連クラスの宣言
3+
4+//--------------------------------------------------------------------------------
5+//
6+// OpenXOPS
7+// Copyright (c) 2014-2020, OpenXOPS Project / [-_-;](mikan) All rights reserved.
8+//
9+// Redistribution and use in source and binary forms, with or without
10+// modification, are permitted provided that the following conditions are met:
11+// * Redistributions of source code must retain the above copyright notice,
12+// this list of conditions and the following disclaimer.
13+// * Redistributions in binary form must reproduce the above copyright notice,
14+// this list of conditions and the following disclaimer in the documentation
15+// and/or other materials provided with the distribution.
16+// * Neither the name of the OpenXOPS Project nor the names of its contributors
17+// may be used to endorse or promote products derived from this software
18+// without specific prior written permission.
19+//
20+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+// DISCLAIMED. IN NO EVENT SHALL OpenXOPS Project BE LIABLE FOR ANY
24+// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+//--------------------------------------------------------------------------------
31+
32+#ifndef OBJECT2D_H
33+#define OBJECT2D_H
34+
35+#ifndef H_LAYERLEVEL
36+ #define H_LAYERLEVEL 2 //!< Select include file.
37+#endif
38+#include "main.h"
39+
40+//! @brief スクロールバーの管理描画クラス
41+//! @details スクロールバーの処理や描画を行います。
42+//! @attention 縦/Y軸方向のスクロールしか想定していません。
43+class ScrollbarObject
44+{
45+ int pos_x; //!< x座標
46+ int pos_y; //!< y座標
47+ int width; //!< 幅
48+ int height; //!< 高さ
49+ int totalitems; //!< 合計アイテム数
50+ int showtems; //!< 表示するアイテム数
51+ int scrollitem; //!< スクロールしたアイテム数
52+ float knob_height; //!< ノブの高さ
53+ float knob_scale; //!< ノブの目盛
54+ int knob_y; //!< ノブのY座標
55+ int mouse_mode; //!< マウスによる選択状況
56+ int color_body; //!< 本体の色
57+ int color1_default; //!< 通常時の色(外側)
58+ int color2_default; //!< 通常時の色(内側)
59+ int color1_cursor; //!< カーソル選択時の色(外側)
60+ int color2_cursor; //!< カーソル選択時の色(内側)
61+ int color1_select; //!< クリック時の色(外側)
62+ int color2_select; //!< クリック時の色(内側)
63+
64+public:
65+ ScrollbarObject();
66+ ~ScrollbarObject();
67+ void Create(int x, int y, int w, int h, int in_totalitems, int in_showtems, int in_scrollitem);
68+ void SetColor(int body, int default1, int default2, int cursor1, int cursor2, int select1, int select2);
69+ void SetScrollItem(int id);
70+ int GetScrollItem();
71+ void ScrollUP();
72+ void ScrollDOWN();
73+ void Input(int mouse_x, int mouse_y, bool mouse_click, int scroll_y);
74+ void Draw(class D3DGraphics *d3dg);
75+};
76+
77+#endif
\ No newline at end of file
--- trunk/main.h (revision 231)
+++ trunk/main.h (revision 232)
@@ -117,6 +117,7 @@
117117 #include "collision.h"
118118 #include "object.h"
119119 #include "soundmanager.h"
120+ #include "gui-object.h"
120121 #endif
121122
122123 //高レイヤー