CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/Dialog/PSPDialog.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include "Common/CommonTypes.h"20#include "Common/Render/TextureAtlas.h"21#include "Common/Swap.h"22#include "Core/HLE/sceUtility.h"23#include "Core/Util/PPGeDraw.h"2425class PointerWrap;2627#define SCE_UTILITY_DIALOG_RESULT_SUCCESS 028#define SCE_UTILITY_DIALOG_RESULT_CANCEL 129#define SCE_UTILITY_DIALOG_RESULT_ABORT 23031const int SCE_ERROR_UTILITY_INVALID_STATUS = 0x80110001;32const int SCE_ERROR_UTILITY_INVALID_PARAM_SIZE = 0x80110004;33const int SCE_ERROR_UTILITY_WRONG_TYPE = 0x80110005;34const int ERROR_UTILITY_INVALID_ADHOC_CHANNEL = 0x80110104;35const int ERROR_UTILITY_INVALID_SYSTEM_PARAM_ID = 0x80110103;3637struct pspUtilityDialogCommon38{39u32_le size; /** Size of the structure */40s32_le language; /** Language */41s32_le buttonSwap; /** Set to 1 for X/O button swap */42s32_le graphicsThread; /** Graphics thread priority */43s32_le accessThread; /** Access/fileio thread priority (SceJobThread) */44s32_le fontThread; /** Font thread priority (ScePafThread) */45s32_le soundThread; /** Sound thread priority */46s32_le result; /** Result */47s32_le reserved[4]; /** Set to 0 */48};495051class PSPDialog52{53public:54PSPDialog(UtilityDialogType type);55virtual ~PSPDialog();5657virtual int Update(int animSpeed) = 0;58virtual int Shutdown(bool force = false);59virtual void DoState(PointerWrap &p);60virtual pspUtilityDialogCommon *GetCommonParam();6162enum DialogStatus63{64SCE_UTILITY_STATUS_NONE = 0,65SCE_UTILITY_STATUS_INITIALIZE = 1,66SCE_UTILITY_STATUS_RUNNING = 2,67SCE_UTILITY_STATUS_FINISHED = 3,68SCE_UTILITY_STATUS_SHUTDOWN = 4,69SCE_UTILITY_STATUS_SCREENSHOT_UNKNOWN = 5,70};7172enum DialogStockButton73{74DS_BUTTON_NONE = 0x00,75DS_BUTTON_OK = 0x01,76DS_BUTTON_CANCEL = 0x02,77DS_BUTTON_BOTH = 0x03,78};7980DialogStatus GetStatus();81UtilityDialogType DialogType() { return dialogType_; }8283void StartDraw();84void EndDraw();8586void FinishVolatile();87int FinishInit();88int FinishShutdown();8990protected:91void InitCommon();92void UpdateCommon();93PPGeStyle FadedStyle(PPGeAlign align, float scale);94PPGeImageStyle FadedImageStyle();95void UpdateButtons();96bool IsButtonPressed(int checkButton);97bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10);98// The caption override is assumed to have a size of 64 bytes.99void DisplayButtons(int flags, std::string_view caption = "");100void ChangeStatus(DialogStatus newStatus, int delayUs);101void ChangeStatusInit(int delayUs);102void ChangeStatusShutdown(int delayUs);103DialogStatus ReadStatus() const {104return status;105}106107// TODO: Remove this once all dialogs are updated.108virtual bool UseAutoStatus() = 0;109110static int GetConfirmButton();111static int GetCancelButton();112113void StartFade(bool fadeIn_);114void UpdateFade(int animSpeed);115virtual void FinishFadeOut();116u32 CalcFadedColor(u32 inColor) const;117118DialogStatus pendingStatus = SCE_UTILITY_STATUS_NONE;119u64 pendingStatusTicks = 0;120121unsigned int lastButtons = 0;122unsigned int buttons = 0;123124float fadeTimer = 0.0f;125bool isFading = false;126bool fadeIn = false;127u32 fadeValue = 0;128129ImageID okButtonImg;130ImageID cancelButtonImg;131int okButtonFlag;132int cancelButtonFlag;133134private:135DialogStatus status = SCE_UTILITY_STATUS_NONE;136UtilityDialogType dialogType_ = UtilityDialogType::NONE;137bool volatileLocked_ = false;138};139140141