JNR
uiWatch.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 // uiWatch.cpp
32 // Dependent: -
33 //
34 // This window is designed for debug purpoces. Add variables and monitor their values
35 //
36 #include "stdafx.h"
37 #include "GUI.h"
38 
39 uiWatch *g_puiWatch = NULL;
40 
41 uiWatch::uiWatch(): uiContainer()
42 {
43 }
44 
45 uiWatch::~uiWatch()
46 {
47 }
48 
49 void uiWatch::Set(char* strVar, char* strFormat, ...)
50 {
51  char text[256];
52  va_list ap;
53  va_start(ap, strFormat);
54  vsprintf(text, strFormat, ap);
55  va_end(ap);
56 
57  unsigned i;
58  char s[128];
59 
60  //Update
61  for(i=0; i<32; i++)
62  {
63  if(m_arEntires[i].bUsed)
64  {
65  m_arEntires[i].name.getText(s);
66  s[strlen(s)-1]='\0';
67  if(!strcmp(s, strVar))
68  {
69  m_arEntires[i].val.setText(strFormat);
70  return;
71  }
72  }
73  }
74 
75  //Insert
76  for(i=0; i<32; i++)
77  {
78  if(!m_arEntires[i].bUsed)
79  {
80  strcpy(s, strVar);
81  strcat(s, ":");
82  m_arEntires[i].bUsed = true;
83  m_arEntires[i].name.create(laPoint3(0,50+m_nCnt*20), laPoint3(150,100));
84  m_arEntires[i].name.setText(s);
85  //m_arEntires[i].name[0]= 0; m_arEntires[i].name[1]= 0; m_arEntires[i].name[2]= 0;
86  insert(&(m_arEntires[i].name));
87 
88  m_arEntires[i].bUsed = true;
89  m_arEntires[i].val.create(laPoint3(0,50+m_nCnt*20),laPoint3(80,100));
90  m_arEntires[i].val.setText(text);
91  //m_arEntires[i].val[0]= 0; m_arEntires[i].val[1]= 0; m_arEntires[i].val[2]= 0.5;
92  insert(&(m_arEntires[i].val));
93  //MetricRight(&(m_arEntires[i].val));
94 
95  m_nCnt++;
96  return;
97  }
98  }
99 }
100 
101 void uiWatch::create(laPoint3 pos, laPoint3 size)
102 {
103  uiContainer::create(pos,size);
104  caption.setText("System Watch");
105 
106  m_nCnt = 0;
107  for(unsigned i=0; i<32; i++) m_arEntires[i].bUsed = false;
108 }
109 
111 {
113 }
void kill()
Discard window and all children.
GUI Container Window.
Definition: uiContainer.h:42
void kill()
Discard window and all children.
Definition: uiWatch.cpp:110
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: uiLabel.cpp:52
virtual void create(laPoint3 pos, laPoint3 size)
Create new empty window.
Definition: uiContainer.cpp:97
uiLabel caption
Caption.
Definition: uiContainer.h:83