JNR
uiDesktop.cpp
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 
30 //
31 // uiDesktop.cpp
32 // Dependent: -
33 //
34 // Window containing all the user interface widgets and windows
35 //
36 #include "stdafx.h"
37 #include "GUI.h"
38 
39 //uiDesktop* g_pDesktop = NULL;
40 
41 uiDesktop::uiDesktop()
42 {
43 }
44 
45 uiDesktop::~uiDesktop()
46 {
47 }
48 
49 void uiDesktop::create(char* strDesktopName)
50 {
51  laSettings *s = laSystemIntegrator::getSettings();
52  laFileParser fp(strDesktopName);
53 
54  // Load skin
55  char strSkin[64];
56  fp.readSectionSeparator();
57  fp.readText(strSkin);
58 
59  m_uiSkin.load(strSkin);
60  m_uiSkin.activate();
61 
62  // Create cursor object
63  m_uiPtr.Create();
64  uiWindow::_pPointer = &m_uiPtr;
65 
66  // Create the root container
67  uiContainer::create(laPoint3(), laPoint3(s->graphics_resolution_w, s->graphics_resolution_h));
68  toggleBorders(M_FALSE);
69  toggleMoveable(M_FALSE);
70 
71  // Create a variable watch window
72  if(g_puiWatch==NULL)
73  {
74  g_puiWatch = new uiWatch;
75  g_puiWatch->create(laPoint3(s->graphics_resolution_w-260, 10), laPoint3(250,500) );
76  insert(g_puiWatch);
77  g_puiWatch->hide();
78  }
79  //g_pDesktop = this;
80 
81  //Create sky
82  fp.readSectionSeparator();
83  fp.readObj( &_cbSky );
84 }
85 
87 {
88  //Destroy stuff
90  m_uiPtr.kill();
91  m_uiSkin.kill();
92 }
93 
94 void uiDesktop::drawBackground()
95 {
96  laRenderer* pr = ::laSystemIntegrator::getRenderer();
97  laTimer* t = laSystemIntegrator::getEnvironment()->getTimer();
98 
99  // Draw and animate the sky
100  // NOTE: Background is normaly drawn in GUI mode, where a blend filter is normaly set,
101  // but we don't want it for the sky
102  //
103  double dOldFilter = pr->modeBlendFilter(0);
104  pr->styleBackground( _cbSky._rgbColor );
105 
106  _cbSky.draw(pr);
107  _cbSky.animate(*t);
108 
109  pr->modeBlendFilter( dOldFilter );
110 }
111 
113 {
114  laRenderer* pr = ::laSystemIntegrator::getRenderer();
115  laTimer* t = laSystemIntegrator::getEnvironment()->getTimer();
116 
117  // Draw child windows
119 
120  // Draw pointer
121  m_uiPtr.draw();
122 }
123 
125 {
126  uiWindow::_pPointer = &m_uiPtr;
128 }
void kill()
Discard window and all children.
laTimer * getTimer()
Get inegrated timer.
Definition: laEnvironment.h:85
void kill()
Discard window and all children.
Definition: uiDesktop.cpp:86
void create(laPoint3 pos, laPoint3 size)
Create new empty window.
Definition: uiWatch.cpp:101
Watch Debug Window.
Definition: uiWatch.h:53
virtual void create(laPoint3 pos, laPoint3 size)
Create new empty window.
Definition: uiContainer.cpp:97
virtual void draw()
Display the window.
Game Settings.
Definition: laSettings.h:38
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
void toggleBorders(M_BOOL bEnable)
Toggle border visbility.
Definition: uiContainer.h:87
virtual void reply()
Handle input message.
Definition: uiDesktop.cpp:124
void toggleMoveable(M_BOOL bEnable, unsigned nButton=0)
Toggle moveable flag.
Definition: uiContainer.h:95
virtual void reply()
Handle input message.
virtual double modeBlendFilter(const double &dMinVisisbleAlpha)=0
Set a "blend filter" (cutting out elements with opacity lower than dMinVisisbleAlpha) ...
virtual void draw()
Display the window.
Definition: uiDesktop.cpp:112
File Parser.
Definition: laFileParser.h:41