#include "StageEditor_TopButton.h" #include "StageData.h" #include "ToolLib.h" // セーブボタンの座標と幅 #define SAVEBUTTON_X (SCREEN_WIDTH - 80) #define SAVEBUTTON_Y (SCREEN_HEIGHT - 30) #define SAVEBUTTON_W (50) // ステージ変更ボタンの座標と幅 #define STAGECHANGE_X (SCREEN_WIDTH - STAGECHANGE_W * 2 - 10) #define STAGECHANGE_Y (40) #define STAGECHANGE_W (100) // カメラ速度変更ボタンの座標と幅 #define CAMERASPEED_X (SCREEN_WIDTH - CAMERASPEED_W * 2 - 10) #define CAMERASPEED_Y (130) #define CAMERASPEED_W (80) // 最大カメラ速度と最小カメラ速度 #define CAMERASPEED_MAX (4) #define CAMERASPEED_MIN (-8) // 移動速度変更ボタンの座標と幅 #define MOVESPEED_X (SCREEN_WIDTH - MOVESPEED_W * 2 - 10) #define MOVESPEED_Y (200) #define MOVESPEED_W (80) // 最大移動速度と最小移動速度 #define MOVESPEED_MAX (4) #define MOVESPEED_MIN (-8) // 向き速度変更ボタンの座標と幅 #define ANGLESPEED_X (SCREEN_WIDTH - ANGLESPEED_W * 2 - 10) #define ANGLESPEED_Y (270) #define ANGLESPEED_W (80) // 最大向き変更速度と最小向き変更速度 #define ANGLESPEED_MAX (4) #define ANGLESPEED_MIN (-8) // 拡大率速度変更ボタンの座標と幅 #define SCALESPEED_X (SCREEN_WIDTH - SCALESPEED_W * 2 - 10) #define SCALESPEED_Y (340) #define SCALESPEED_W (80) // 最大拡大率変更速度と最小拡大率変更速度 #define SCALESPEED_MAX (4) #define SCALESPEED_MIN (-8) // 編集モード変更用ボタンや速度変更ボタンなどの処理の情報 typedef struct _STopButtonData { // 編集モード変更用ボタンのハンドル int EditModeTButton[ EEditMode_Num ]; // 各編集モード用の表示状態情報ハンドル int EditModeTVisible[ EEditMode_Num ]; // セーブボタンのハンドル int SaveTButton; // ステージ変更ボタンのハンドル int StageChangePlusTButton; int StageChangeMinusTButton; // カメラ速度変更ボタンのハンドル int CameraSpeedPlusTButton; int CameraSpeedMinusTButton; // 移動速度変更ボタンのハンドル int MoveSpeedPlusTButton; int MoveSpeedMinusTButton; // 角度速度変更ボタンのハンドル int AngleSpeedPlusTButton; int AngleSpeedMinusTButton; // 拡大率速度変更ボタンのハンドル int ScaleSpeedPlusTButton; int ScaleSpeedMinusTButton; } STopButtonData; // 各編集モードのボタン上に表示する名前 const char *g_EditModeButtonName[ EEditMode_Num ] = { "キャラ", "オブジェクト", "イベント", "クリア条件", // "サウンド", }; STopButtonData g_TBData; // 編集モード変更用ボタンや速度変更ボタンなどの処理の初期化を行う // 戻り値 : 処理が正常に終了したかどうか(true:正常に終了した false:エラーが発生した) bool StageEditor_TopButton_Initialize( void ) { int i; // 各編集モードに変更するためのボタンと表示状態情報ハンドルの作成 for( i = 0; i < EEditMode_Num; i++ ) { g_TBData.EditModeTButton[ i ] = ToolButton_Create( true, g_EditModeButtonName[ i ], TOPBUTTON_X + TOPBUTTON_W * i, TOPBUTTON_Y, TOPBUTTON_W, TOPBUTTON_H ); if( g_TBData.EditModeTButton[ i ] == -1 ) { return false; } g_TBData.EditModeTVisible[ i ] = ToolVisible_Create(); if( g_TBData.EditModeTVisible[ i ] == -1 ) { return false; } ToolButton_SetVisible( g_TBData.EditModeTButton[ i ], true ); } // セーブボタンの作成 g_TBData.SaveTButton = ToolButton_Create( false, "SAVE", SAVEBUTTON_X, SAVEBUTTON_Y, SAVEBUTTON_W, BUTTON_H ); if( g_TBData.SaveTButton == -1 ) { return false; } // ステージ変更ボタンの作成 g_TBData.StageChangePlusTButton = ToolButton_Create( false, "編集ステージ変更+", STAGECHANGE_X, STAGECHANGE_Y, STAGECHANGE_W, BUTTON_H ); if( g_TBData.StageChangePlusTButton == -1 ) { return false; } g_TBData.StageChangeMinusTButton = ToolButton_Create( false, "編集ステージ変更-", STAGECHANGE_X + STAGECHANGE_W, STAGECHANGE_Y, STAGECHANGE_W, BUTTON_H ); if( g_TBData.StageChangeMinusTButton == -1 ) { return false; } // カメラ速度変更ボタンの作成 g_TBData.CameraSpeedPlusTButton = ToolButton_Create( false, "カメラ速度+", CAMERASPEED_X, CAMERASPEED_Y, CAMERASPEED_W, BUTTON_H ); if( g_TBData.CameraSpeedPlusTButton == -1 ) { return false; } g_TBData.CameraSpeedMinusTButton = ToolButton_Create( false, "カメラ速度-", CAMERASPEED_X + CAMERASPEED_W, CAMERASPEED_Y, CAMERASPEED_W, BUTTON_H ); if( g_TBData.CameraSpeedMinusTButton == -1 ) { return false; } // 移動速度変更ボタンの作成 g_TBData.MoveSpeedPlusTButton = ToolButton_Create( false, "移動速度+", MOVESPEED_X, MOVESPEED_Y, MOVESPEED_W, BUTTON_H ); if( g_TBData.MoveSpeedPlusTButton == -1 ) { return false; } g_TBData.MoveSpeedMinusTButton = ToolButton_Create( false, "移動速度-", MOVESPEED_X + MOVESPEED_W, MOVESPEED_Y, MOVESPEED_W, BUTTON_H ); if( g_TBData.MoveSpeedMinusTButton == -1 ) { return false; } // 角度速度変更ボタンの作成 g_TBData.AngleSpeedPlusTButton = ToolButton_Create( false, "角度速度+", ANGLESPEED_X, ANGLESPEED_Y, ANGLESPEED_W, BUTTON_H ); if( g_TBData.AngleSpeedPlusTButton == -1 ) { return false; } g_TBData.AngleSpeedMinusTButton = ToolButton_Create( false, "角度速度-", ANGLESPEED_X + ANGLESPEED_W, ANGLESPEED_Y, ANGLESPEED_W, BUTTON_H ); if( g_TBData.AngleSpeedMinusTButton == -1 ) { return false; } // 拡大率速度変更ボタンの作成 g_TBData.ScaleSpeedPlusTButton = ToolButton_Create( false, "スケール速度+", SCALESPEED_X, SCALESPEED_Y, SCALESPEED_W, BUTTON_H ); if( g_TBData.ScaleSpeedPlusTButton == -1 ) { return false; } g_TBData.ScaleSpeedMinusTButton = ToolButton_Create( false, "スケール速度-", SCALESPEED_X + SCALESPEED_W, SCALESPEED_Y, SCALESPEED_W, BUTTON_H ); if( g_TBData.ScaleSpeedMinusTButton == -1 ) { return false; } // 正常終了 return true; } // 編集モード変更用ボタンや速度変更ボタンなどの処理の状態推移処理を行う // 戻り値 : 処理が正常に終了したかどうか(true:正常に終了した false:エラーが発生した) bool StageEditor_TopButton_Step( void ) { int i; // セーブボタンが押されたらセーブ処理を行う if( ToolButton_GetClick( g_TBData.SaveTButton, true ) ) { SaveStage(); } // ステージ変更ボタンが押されたらステージを変更する if( ToolButton_GetClick( g_TBData.StageChangePlusTButton, true ) ) { g_StageData.LoadStageNumber++; if( g_StageData.LoadStageNumber == g_StageData.TotalStageNum ) { g_StageData.LoadStageNumber = 0; } if( !LoadStage( g_StageData.LoadStageNumber ) ) { return false; } } if( ToolButton_GetClick( g_TBData.StageChangeMinusTButton, true ) ) { g_StageData.LoadStageNumber++; if( g_StageData.LoadStageNumber == g_StageData.TotalStageNum ) { g_StageData.LoadStageNumber = 0; } if( !LoadStage( g_StageData.LoadStageNumber ) ) { return false; } } // カメラ速度変更ボタンが押されたらカメラ速度を変更する if( ToolButton_GetClick( g_TBData.CameraSpeedPlusTButton, true ) ) { if( g_SEData.Camera.Speed < CAMERASPEED_MAX ) { g_SEData.Camera.Speed++; g_SEData.Camera.SpeedF = 1.0f; if( g_SEData.Camera.Speed > 0 ) { for( i = 0; i < g_SEData.Camera.Speed; i++ ) { g_SEData.Camera.SpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.Camera.Speed; i-- ) { g_SEData.Camera.SpeedF /= 2.0f; } } } } if( ToolButton_GetClick( g_TBData.CameraSpeedMinusTButton, true ) ) { if( g_SEData.Camera.Speed > CAMERASPEED_MIN ) { g_SEData.Camera.Speed--; g_SEData.Camera.SpeedF = 1.0f; if( g_SEData.Camera.Speed > 0 ) { for( i = 0; i < g_SEData.Camera.Speed; i++ ) { g_SEData.Camera.SpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.Camera.Speed; i-- ) { g_SEData.Camera.SpeedF /= 2.0f; } } } } // 移動速度変更ボタンが押されたら移動速度を変更する if( ToolButton_GetClick( g_TBData.MoveSpeedPlusTButton, true ) ) { if( g_SEData.MoveSpeed < MOVESPEED_MAX ) { g_SEData.MoveSpeed++; g_SEData.MoveSpeedF = 1.0f; if( g_SEData.MoveSpeed > 0 ) { for( i = 0; i < g_SEData.MoveSpeed; i++ ) { g_SEData.MoveSpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.MoveSpeed; i-- ) { g_SEData.MoveSpeedF /= 2.0f; } } } } if( ToolButton_GetClick( g_TBData.MoveSpeedMinusTButton, true ) ) { if( g_SEData.MoveSpeed > MOVESPEED_MIN ) { g_SEData.MoveSpeed--; g_SEData.MoveSpeedF = 1.0f; if( g_SEData.MoveSpeed > 0 ) { for( i = 0; i < g_SEData.MoveSpeed; i++ ) { g_SEData.MoveSpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.MoveSpeed; i-- ) { g_SEData.MoveSpeedF /= 2.0f; } } } } // 角度速度変更ボタンが押されたら角度変更速度を変更する if( ToolButton_GetClick( g_TBData.AngleSpeedPlusTButton, true ) ) { if( g_SEData.AngleSpeed < ANGLESPEED_MAX ) { g_SEData.AngleSpeed++; g_SEData.AngleSpeedF = 1.0f; if( g_SEData.AngleSpeed > 0 ) { for( i = 0; i < g_SEData.AngleSpeed; i++ ) { g_SEData.AngleSpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.AngleSpeed; i-- ) { g_SEData.AngleSpeedF /= 2.0f; } } } } if( ToolButton_GetClick( g_TBData.AngleSpeedMinusTButton, true ) ) { if( g_SEData.AngleSpeed > ANGLESPEED_MIN ) { g_SEData.AngleSpeed--; g_SEData.AngleSpeedF = 1.0f; if( g_SEData.AngleSpeed > 0 ) { for( i = 0; i < g_SEData.AngleSpeed; i++ ) { g_SEData.AngleSpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.AngleSpeed; i-- ) { g_SEData.AngleSpeedF /= 2.0f; } } } } // 拡大率速度変更ボタンが押されたら拡大率変更速度を変更する if( ToolButton_GetClick( g_TBData.ScaleSpeedPlusTButton, true ) ) { if( g_SEData.ScaleSpeed < SCALESPEED_MAX ) { g_SEData.ScaleSpeed++; g_SEData.ScaleSpeedF = 1.0f; if( g_SEData.ScaleSpeed > 0 ) { for( i = 0; i < g_SEData.ScaleSpeed; i++ ) { g_SEData.ScaleSpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.ScaleSpeed; i-- ) { g_SEData.ScaleSpeedF /= 2.0f; } } } } if( ToolButton_GetClick( g_TBData.ScaleSpeedMinusTButton, true ) ) { if( g_SEData.ScaleSpeed > SCALESPEED_MIN ) { g_SEData.ScaleSpeed--; g_SEData.ScaleSpeedF = 1.0f; if( g_SEData.ScaleSpeed > 0 ) { for( i = 0; i < g_SEData.ScaleSpeed; i++ ) { g_SEData.ScaleSpeedF *= 2.0f; } } else { for( i = 0; i > g_SEData.ScaleSpeed; i-- ) { g_SEData.ScaleSpeedF /= 2.0f; } } } } // 編集モード変更ボタンが押されたら各編集モードの表示状態をリセットした後 // 選択された編集モードの表示状態をONにする for( i = 0; i < EEditMode_Num; i++ ) { if( !ToolButton_GetClick( g_TBData.EditModeTButton[ i ], true ) ) { continue; } StageEditor_TopButton_UIReset(); // 既に押されていたボタンがもう一度押された場合は何も表示しない状態にする if( g_SEData.EditMode == ( EEditMode )i ) { g_SEData.EditMode = EEditMode_Num; } else { g_SEData.EditMode = ( EEditMode )i; ToolButton_SetOnOffFlag( g_TBData.EditModeTButton[ i ], true ); ToolVisible_SetVisible( g_TBData.EditModeTVisible[ i ], true ); } } // 正常終了 return true; } // 編集モード変更用ボタンや速度変更ボタンなどの処理の描画処理を行う void StageEditor_TopButton_Render( void ) { int WhiteColor; WhiteColor = GetColor( 255,255,255 ); DrawFormatString( SCREEN_WIDTH - 144, STAGECHANGE_Y - 30, WhiteColor, "編集ステージ:%d", g_StageData.LoadStageNumber ); DrawFormatString( SCREEN_WIDTH - 204, CAMERASPEED_Y - 30, WhiteColor, " カメラ速度:%.3f倍", g_SEData.Camera.SpeedF ); DrawFormatString( SCREEN_WIDTH - 204, MOVESPEED_Y - 30, WhiteColor, "  移動速度:%.3f倍", g_SEData.MoveSpeedF ); DrawFormatString( SCREEN_WIDTH - 204, ANGLESPEED_Y - 30, WhiteColor, "角度変更速度:%.3f倍", g_SEData.AngleSpeedF ); DrawFormatString( SCREEN_WIDTH - 204, SCALESPEED_Y - 30, WhiteColor, "スケール変更速度:%.3f倍", g_SEData.ScaleSpeedF ); } // 各編集モードの表示状態情報ハンドルを取得する // 戻り値 : 指定の編集モードの表状態情報ハンドル int StageEditor_TopButton_GetEditModeVisibleHandle( // 表示状態情報ハンドルを取得したい編集モード EEditMode EditMode ) { return g_TBData.EditModeTVisible[ EditMode ]; } // 編集モード変更用ボタンや各編集モードの表示状態をリセットする void StageEditor_TopButton_UIReset( void ) { int i; for( i = 0; i < EEditMode_Num; i++ ) { ToolButton_SetOnOffFlag( g_TBData.EditModeTButton[ i ], false ); ToolVisible_SetVisible( g_TBData.EditModeTVisible[ i ], false ); } }