1 /****************************************************************************
4 Copyright (c) 2001-2008 Jerome Jacovella-St-Louis
7 console.ec - Console Dialog
8 ****************************************************************************/
13 class Console : Window
20 textHorzScroll = true;
21 textVertScroll = true;
27 this, textHorzScroll = true; size.h = editHeight, anchor = { left = 0, right = 0, bottom = 0 };
29 virtual bool ProcessCommand(char * command);
35 char currentCommand[256];
63 double realTime, diffTime;
66 diffTime = realTime - lastTime;
68 /* CONSOLE MOVEMENT */
71 int movement = (int)(diffTime * (movement * speed));
76 pos = Max(pos, -size.h);
78 if(pos == -size.h && movement == -1)
80 // eWindow_Hide(window, true, false);
85 Move(position.x, (int)pos, clientSize.w, clientSize.h);
86 if(!pos && movement == 1)
89 // Set up transparency color
91 currentAlpha = (((int)pos + size.h) * alpha / size.h);
93 log.foreground = (logTextColor & 0xFFFFFF) | (currentAlpha << 24);
96 commandBox.foreground = (editTextColor & 0xFFFFFF) | ((currentAlpha * 255 / alpha) << 24);
98 commandBox.background = (editBackColor & 0xFFFFFF) | (currentAlpha << 24);
111 commands.circ = true;
115 referenceHeight = 768;
118 // h = height * 768 / referenceHeight;
120 // Set up transparency color
121 currentAlpha = (((int)pos + size.h) * alpha / size.h);
124 referenceHeight = 768;
126 editHeight = this.editHeight * 768 / referenceHeight;
128 log.anchor = { left = 0, top = 0, right = 0, bottom = editHeight + separatorHeight* 768/referenceHeight };
135 log.foreground = (logTextColor & 0xFFFFFF) | (currentAlpha << 24);
137 commandBox.foreground = (editTextColor & 0xFFFFFF) | ((currentAlpha * 255 / alpha) << 24);
138 commandBox.background = (editBackColor & 0xFFFFFF) | (currentAlpha << 24);
147 bool OnLoadGraphics()
150 bitmap.Load(bmpFile, null, displaySystem);
154 void OnUnloadGraphics()
159 void OnRedraw(Surface surface)
161 surface.SetForeground(white);
163 surface.Stretch(bitmap, 0, 0, 0, 0, clientSize.w, clientSize.h, bitmap.width, bitmap.height);
166 surface.SetForeground((logTextColor & 0xFFFFFF) | (currentAlpha << 24));
169 clientSize.w - verLROffset.x * 768 / referenceHeight,
170 clientSize.h - verLROffset.y * 768 / referenceHeight,
175 bool OnKeyDown(Key key, unichar ch)
177 switch((SmartKey)key)
188 // Process Command in command edit box here
189 lineBuffer = commandBox.line.text;
191 if(lineBuffer && lineBuffer[0])
193 string = (Item)new0 byte[sizeof(class Item) + strlen(lineBuffer) + 1];
196 commands.Add(string);
197 buffer = (char *) ((byte *) string + sizeof(class Item));
198 strcpy(buffer, lineBuffer);
199 command = commands.first;
203 if(log.numLines > 1 || log.line.count)
206 log.PutS(lineBuffer);
209 if(ProcessCommand(lineBuffer))
221 bool OnKeyHit(Key key, unichar ch)
223 char * lineBuffer = commandBox.line.text;
226 switch((SmartKey)key)
237 buffer = (char *) ((byte *) command + sizeof(class Item));
238 if(strcmp(buffer, lineBuffer))
240 strcpy(currentCommand, lineBuffer);
242 if(command == commands.first && !doneLooping)
246 commandBox.PutS(currentCommand);
251 command = command.prev;
253 commandBox.PutS(((byte *) command) + sizeof(class Item));
260 buffer = (char *) ((byte *) command + sizeof(class Item));
261 if(strcmp(buffer, lineBuffer))
263 strcpy(currentCommand, lineBuffer);
265 if(command == commands.last && !doneLooping)
269 commandBox.PutS(currentCommand);
274 command = command.next;
276 commandBox.PutS(((byte *) command) + sizeof(class Item));
292 movement = -movement;
295 SetState(normal, true, 0);
296 commandBox.Activate();
297 lastTime = GetTime();
301 void Log(char * format, ...)
305 char text[MAX_F_STRING];
308 va_start(args, format);
309 vsprintf(text, format, args);