CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/EmuScreen.h
Views: 1401
1
// Copyright (c) 2012- 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 <list>
21
#include <string>
22
#include <vector>
23
24
#include "Common/File/Path.h"
25
#include "Common/Input/KeyCodes.h"
26
#include "Common/UI/Screen.h"
27
#include "Common/UI/UIScreen.h"
28
#include "Common/UI/Tween.h"
29
#include "Core/KeyMap.h"
30
#include "Core/ControlMapper.h"
31
32
struct AxisInput;
33
34
class AsyncImageFileView;
35
class ChatMenu;
36
37
class EmuScreen : public UIScreen {
38
public:
39
EmuScreen(const Path &filename);
40
~EmuScreen();
41
42
const char *tag() const override { return "Emu"; }
43
44
void update() override;
45
ScreenRenderFlags render(ScreenRenderMode mode) override;
46
void dialogFinished(const Screen *dialog, DialogResult result) override;
47
void sendMessage(UIMessage message, const char *value) override;
48
void resized() override;
49
ScreenRenderRole renderRole(bool isTop) const override;
50
51
// Note: Unlike your average boring UIScreen, here we override the Unsync* functions
52
// to get minimal latency and full control. We forward to UIScreen when needed.
53
bool UnsyncTouch(const TouchInput &touch) override;
54
bool UnsyncKey(const KeyInput &key) override;
55
void UnsyncAxis(const AxisInput *axes, size_t count) override;
56
57
// We also need to do some special handling of queued UI events to handle closing the chat window.
58
bool key(const KeyInput &key) override;
59
60
protected:
61
void darken();
62
void focusChanged(ScreenFocusChange focusChange) override;
63
64
private:
65
void CreateViews() override;
66
UI::EventReturn OnDevTools(UI::EventParams &params);
67
UI::EventReturn OnDisableCardboard(UI::EventParams &params);
68
UI::EventReturn OnChat(UI::EventParams &params);
69
UI::EventReturn OnResume(UI::EventParams &params);
70
71
void bootGame(const Path &filename);
72
bool bootAllowStorage(const Path &filename);
73
void bootComplete();
74
bool hasVisibleUI();
75
void renderUI();
76
77
void onVKey(int virtualKeyCode, bool down);
78
void onVKeyAnalog(int virtualKeyCode, float value);
79
80
void autoLoad();
81
bool checkPowerDown();
82
83
UI::Event OnDevMenu;
84
UI::Event OnChatMenu;
85
bool bootPending_ = true;
86
Path gamePath_;
87
88
// Something invalid was loaded, don't try to emulate
89
bool invalid_ = true;
90
bool quit_ = false;
91
bool stopRender_ = false;
92
std::string errorMessage_;
93
94
// If set, pauses at the end of the frame.
95
bool pauseTrigger_ = false;
96
97
// The last read chat message count, and how many new ones there are.
98
int chatMessages_ = 0;
99
int newChatMessages_ = 0;
100
101
// In-memory save state used for freezeFrame, which is useful for debugging.
102
std::vector<u8> freezeState_;
103
104
std::string tag_;
105
106
double saveStatePreviewShownTime_ = 0.0;
107
AsyncImageFileView *saveStatePreview_ = nullptr;
108
int saveStateSlot_;
109
110
UI::CallbackColorTween *loadingViewColor_ = nullptr;
111
UI::VisibilityTween *loadingViewVisible_ = nullptr;
112
UI::Spinner *loadingSpinner_ = nullptr;
113
UI::TextView *loadingTextView_ = nullptr;
114
UI::Button *resumeButton_ = nullptr;
115
UI::Button *resetButton_ = nullptr;
116
UI::Button *backButton_ = nullptr;
117
UI::View *chatButton_ = nullptr;
118
ChatMenu *chatMenu_ = nullptr;
119
120
UI::Button *cardboardDisableButton_ = nullptr;
121
122
std::string extraAssertInfoStr_;
123
124
std::atomic<bool> doFrameAdvance_{};
125
126
ControlMapper controlMapper_;
127
};
128
129