Rise
The Vieneo Province
Loading...
Searching...
No Matches
Screen.h
Go to the documentation of this file.
1#pragma once
2
3#include "Page.h"
4
5class Screen
6{
7 //Logger* logger;
8 //D3D10_VIEWPORT viewport;
9 //DeviceObject* pDevice;
10 //ID3DX10Font* pFont = nullptr;
11 //ID3D10RasterizerState* state = nullptr;
12 int lastPage = -1;
15 char* vdat;
16
17public:
18 /*
19 RiseMath::Matrix matProjection;
20 RiseMath::Matrix matView;
21 bool initialized = false;*/
22 UINT currentPage = 0;
23
24 // config items
25 std::string name;
26 bool bypassVdat = false;
27 std::vector<Page> pages;
28
29 int width = 0;
30 int height = 0;
31 int x = 0;
32 int y = 0;
33 RECT rect = RECT();
34
35 bool Render()
36 {
37 // @todo we want to add effects for values between 1 and 126 like color weirdness, blocks, weird fonts, etc
38 if (!bypassVdat && *vdat <= 0)
39 return false;
40
41 if (currentPage >= pages.size())
42 throw std::exception("Tried to render a current page that is outside of the pages collection!");
43
44 pages.at(currentPage).Render();
45
46 return true;
47 }
48
50 {
51 pages.clear();
52 }
53
54 bool HandleKeyPress(short key, bool shift)
55 {
56 if (currentPage >= pages.size())
57 throw std::exception("Tried to handle keypress for current page that is outside of the pages collection!");
58 return pages.at(currentPage).HandleKeyPress(key, shift);
59 }
60
61 bool UpdateKeyRepeat(const unsigned char* keys, bool shift, float elapsed)
62 {
63 if (currentPage >= pages.size()) return false;
64 return pages.at(currentPage).UpdateKeyRepeat(
65 bypassVdat || *vdat > 0 ? keys : nullptr, shift, elapsed);
66 }
67
68 void FrameMove(float fElapsed)
69 {
70 Rendering::ProfileCpuScope11 screenTiming("Screen", name.c_str());
71 if (currentPage >= pages.size())
72 throw std::exception("Tried to frameMove a current page that is outside of the pages collection!");
73 pages.at(currentPage).FrameMove(fElapsed);
74 }
75
76 bool ChangePage(const std::string& pageName)
77 {
78 for (UINT i = 0; i < pages.size(); i++)
79 {
80 if (pages.at(i).name == pageName)
81 {
82 ChangePage(i);
83 return true;
84 }
85 }
86 return false;
87 }
88
89 void OnPageChange(bool sendUpdate = true)
90 {
91 pages.at(currentPage).OnPageChanged();
92
93 if (!sendUpdate)
94 return;
95
96 Command command;
97 command.name = "UpdateMfdPage";
98 command.ivalues[0] = currentPage;
99 command.ivalues[1] = lastPage;
100 bus->commandStream.emplace_back(command);
101 }
102
103 void ChangePage(UINT i)
104 {
105 if (currentPage == i)
106 return; // no change
107
108 if (i < 0 || i >= pages.size())
109 throw std::exception("Tried to ChangePage using a current page that is outside of the pages collection!");
110
112 currentPage = i;
113
114 OnPageChange(false);
115 }
116
118 {
119 if (lastPage != -1)
120 {
122 lastPage = -1;
124 throw std::exception("Tried to RestorePage on a current page that is outside of the pages collection!");
125 OnPageChange();
126 }
127 }
128
130 {
131 bus = nullptr;
132 vdat = nullptr;
133 }
134
135 Screen(Bus* prmBus, char* prmVdat)
136 {
137 bus = prmBus;
138 vdat = prmVdat;
139 }
140};
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
Definition Bus.h:20
std::vector< Command > commandStream
Definition Bus.h:442
std::string name
Definition Screen.h:25
Screen(Bus *prmBus, char *prmVdat)
Definition Screen.h:135
int y
Definition Screen.h:32
bool bypassVdat
Definition Screen.h:26
~Screen()
Definition Screen.h:49
int width
Definition Screen.h:29
bool Render()
Definition Screen.h:35
int height
Definition Screen.h:30
char * vdat
Definition Screen.h:15
int x
Definition Screen.h:31
void ChangePage(UINT i)
Definition Screen.h:103
Bus * bus
Definition Screen.h:14
RECT rect
Definition Screen.h:33
bool HandleKeyPress(short key, bool shift)
Definition Screen.h:54
void FrameMove(float fElapsed)
Definition Screen.h:68
std::vector< Page > pages
Definition Screen.h:27
HRESULT hr
Definition Screen.h:13
int lastPage
Definition Screen.h:12
UINT currentPage
Definition Screen.h:22
bool UpdateKeyRepeat(const unsigned char *keys, bool shift, float elapsed)
Definition Screen.h:61
void RestorePage()
Definition Screen.h:117
Screen()
Definition Screen.h:129
bool ChangePage(const std::string &pageName)
Definition Screen.h:76
void OnPageChange(bool sendUpdate=true)
Definition Screen.h:89
int ivalues[2]
Definition Command.h:21
std::string name
Definition Command.h:11