[Scummvm-cvs-logs] SF.net SVN: scummvm: [23892] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Sep 16 19:29:49 CEST 2006


Revision: 23892
          http://svn.sourceforge.net/scummvm/?rev=23892&view=rev
Author:   fingolfin
Date:     2006-09-16 10:29:43 -0700 (Sat, 16 Sep 2006)

Log Message:
-----------
Added GUI::ConsoleDialoggetCharsPerLine() method, and added a big FIXME comment to gui/console.h

Modified Paths:
--------------
    scummvm/trunk/gui/console.h
    scummvm/trunk/gui/debugger.cpp
    scummvm/trunk/gui/debugger.h

Modified: scummvm/trunk/gui/console.h
===================================================================
--- scummvm/trunk/gui/console.h	2006-09-16 17:26:40 UTC (rev 23891)
+++ scummvm/trunk/gui/console.h	2006-09-16 17:29:43 UTC (rev 23892)
@@ -31,11 +31,44 @@
 
 class ScrollBarWidget;
 
+/*
+ FIXME #1: The console dialog code has some fundamental problems. 
+ First of, note the conflict between the (constant) value kCharsPerLine, and the
+ (variable) value _pageWidth. Look a bit at the code get familiar with them,
+ then return...
+ Now, why don't we just drop kCharsPerLine? Because of the problem of resizing!
+ When the user changes the scaler, the console will get resized. If the dialog
+ becomes smaller because of this, we may have to rewrap text. If the resolution
+ is then increased again, we'd end up with garbled content.
+ 
+ One can now either ignore this problem (and modify our code accordingly to 
+ implement this simple rewrapping -- we currently don't do that at all!).
+ 
+ Or, one can go and implement a more complete console, by replacing the
+ _buffer by a real line buffer -- an arrach of char* pointers.
+ This will allow one to implement resizing perfectly, but has the drawback
+ of making things like scrolling, drawing etc. more complicated.
+ 
+ Either way, the current situation is bad, and we should resolve it one way
+ or the other (and if you can think of a thirds, feel free to suggest it).
+ 
+ 
+ 
+ FIXME #2: Another problem is that apparently _pageWidth isn't computed quite
+ correctly. The current line ends well before reaching the right side of the
+ console dialog. That's irritating and should be fixed.
+ 
+ 
+ FIXME #3: The scroll bar is not shown initially, but the area it would 
+ occupy is not used for anything else. As a result, the gap described above
+ becomes even wider and thus even more irritating.
+*/
 class ConsoleDialog : public Dialog {
 public:
 	typedef bool (*InputCallbackProc)(ConsoleDialog *console, const char *input, void *refCon);
 	typedef bool (*CompletionCallbackProc)(ConsoleDialog* console, const char *input, char*& completion, void *refCon);
 
+protected:
 	enum {
 		kBufferSize	= 32768,
 		kCharsPerLine = 128,
@@ -44,7 +77,6 @@
 		kHistorySize = 20
 	};
 
-protected:
 	const Graphics::Font *_font;
 
 	char	_buffer[kBufferSize];
@@ -123,6 +155,10 @@
 		_completionCallbackProc = proc;
 		_completionCallbackRefCon = refCon;
 	}
+	
+	int getCharsPerLine() {
+		return _pageWidth;
+	}
 
 protected:
 	inline char &buffer(int idx) {

Modified: scummvm/trunk/gui/debugger.cpp
===================================================================
--- scummvm/trunk/gui/debugger.cpp	2006-09-16 17:26:40 UTC (rev 23891)
+++ scummvm/trunk/gui/debugger.cpp	2006-09-16 17:29:43 UTC (rev 23892)
@@ -366,6 +366,7 @@
 // nicely word-wrapped.
 bool Debugger::Cmd_Help(int argc, const char **argv) {
 
+	const int charsPerLine = _debuggerDialog->getCharsPerLine();
 	int width, size, i;
 
 	DebugPrintf("Commands are:\n");
@@ -373,7 +374,7 @@
 	for (i = 0; i < _dcmd_count; i++) {
 		size = strlen(_dcmds[i].name) + 1;
 
-		if ((width + size) >= GUI::ConsoleDialog::kCharsPerLine) {
+		if ((width + size) >= charsPerLine) {
 			DebugPrintf("\n");
 			width = size;
 		} else
@@ -390,7 +391,7 @@
 		for (i = 0; i < _dvar_count; i++) {
 			size = strlen(_dvars[i].name) + 1;
 	
-			if ((width + size) >= GUI::ConsoleDialog::kCharsPerLine) {
+			if ((width + size) >= charsPerLine) {
 				DebugPrintf("\n");
 				width = size;
 			} else

Modified: scummvm/trunk/gui/debugger.h
===================================================================
--- scummvm/trunk/gui/debugger.h	2006-09-16 17:26:40 UTC (rev 23891)
+++ scummvm/trunk/gui/debugger.h	2006-09-16 17:29:43 UTC (rev 23892)
@@ -101,15 +101,14 @@
 	int _frame_countdown;
 	bool _detach_now;
 	
+private:
 	// TODO: Consider replacing the following two arrays by a Hashmap
-
 	int _dvar_count;
 	DVar _dvars[256];
 
 	int _dcmd_count;
 	DCmd _dcmds[256];
 
-private:
 	bool _isAttached;
 	char *_errStr;
 	bool _firstTime;
@@ -129,7 +128,6 @@
 
 	
 private:
-//protected:
 	void detach();
 	void enter();
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list