1 // Copyright (c) 2014- PPSSPP Project. 2 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, version 2.0 or later versions. 6 7 // This program is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 // GNU General Public License 2.0 for more details. 11 12 // A copy of the GPL 2.0 should have been included with the program. 13 // If not, see http://www.gnu.org/licenses/ 14 15 // Official git repository and contact information can be found at 16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. 17 18 #pragma once 19 20 #include <functional> 21 #include <memory> 22 23 #include "Common/File/Path.h" 24 #include "Common/UI/UIScreen.h" 25 #include "Common/UI/ViewGroup.h" 26 #include "UI/MiscScreens.h" 27 #include "UI/TextureUtil.h" 28 29 class GamePauseScreen : public UIDialogScreenWithGameBackground { 30 public: GamePauseScreen(const Path & filename)31 GamePauseScreen(const Path &filename) : UIDialogScreenWithGameBackground(filename), gamePath_(filename) {} 32 virtual ~GamePauseScreen(); 33 34 virtual void dialogFinished(const Screen *dialog, DialogResult dr) override; 35 36 protected: 37 virtual void CreateViews() override; 38 virtual void update() override; 39 void CallbackDeleteConfig(bool yes); 40 41 private: 42 UI::EventReturn OnGameSettings(UI::EventParams &e); 43 UI::EventReturn OnExitToMenu(UI::EventParams &e); 44 UI::EventReturn OnReportFeedback(UI::EventParams &e); 45 46 UI::EventReturn OnRewind(UI::EventParams &e); 47 UI::EventReturn OnLoadUndo(UI::EventParams &e); 48 UI::EventReturn OnLastSaveUndo(UI::EventParams &e); 49 50 UI::EventReturn OnScreenshotClicked(UI::EventParams &e); 51 UI::EventReturn OnCwCheat(UI::EventParams &e); 52 53 UI::EventReturn OnCreateConfig(UI::EventParams &e); 54 UI::EventReturn OnDeleteConfig(UI::EventParams &e); 55 56 UI::EventReturn OnSwitchUMD(UI::EventParams &e); 57 UI::EventReturn OnState(UI::EventParams &e); 58 59 // hack 60 bool finishNextFrame_ = false; 61 Path gamePath_; 62 }; 63 64 // AsyncImageFileView loads a texture from a file, and reloads it as necessary. 65 // TODO: Actually make async, doh. 66 class AsyncImageFileView : public UI::Clickable { 67 public: 68 AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams = 0); 69 ~AsyncImageFileView(); 70 71 void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override; 72 void Draw(UIContext &dc) override; DescribeText()73 std::string DescribeText() const override { return text_; } 74 75 void DeviceLost() override; 76 void DeviceRestored(Draw::DrawContext *draw) override; 77 78 void SetFilename(const Path &filename); SetColor(uint32_t color)79 void SetColor(uint32_t color) { color_ = color; } SetOverlayText(std::string text)80 void SetOverlayText(std::string text) { text_ = text; } SetFixedSize(float fixW,float fixH)81 void SetFixedSize(float fixW, float fixH) { fixedSizeW_ = fixW; fixedSizeH_ = fixH; } SetCanBeFocused(bool can)82 void SetCanBeFocused(bool can) { canFocus_ = can; } 83 CanBeFocused()84 bool CanBeFocused() const override { return canFocus_; } 85 GetFilename()86 const Path &GetFilename() const { return filename_; } 87 88 private: 89 bool canFocus_; 90 Path filename_; 91 std::string text_; 92 uint32_t color_; 93 UI::ImageSizeMode sizeMode_; 94 95 std::unique_ptr<ManagedTexture> texture_; 96 bool textureFailed_; 97 float fixedSizeW_; 98 float fixedSizeH_; 99 }; 100