mirror of
https://github.com/autc04/Retro68.git
synced 2024-06-09 11:29:38 +00:00
Place console in window
This commit is contained in:
parent
5ab8b58291
commit
26b18b2f4c
|
@ -4,13 +4,12 @@
|
||||||
|
|
||||||
Console *Console::currentInstance = NULL;
|
Console *Console::currentInstance = NULL;
|
||||||
|
|
||||||
Console::Console(GrafPtr port)
|
Console::Console(GrafPtr port, Rect r)
|
||||||
: consolePort(port)
|
: consolePort(port), bounds(r)
|
||||||
{
|
{
|
||||||
PortSetter setport(consolePort);
|
PortSetter setport(consolePort);
|
||||||
|
|
||||||
Rect r = {2,2,340,510};
|
InsetRect(&bounds, 2,2);
|
||||||
bounds = r;
|
|
||||||
TextFont(9);
|
TextFont(9);
|
||||||
TextSize(9);
|
TextSize(9);
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ void Console::DrawCell(short x, short y)
|
||||||
void Console::Draw()
|
void Console::Draw()
|
||||||
{
|
{
|
||||||
PortSetter setport(consolePort);
|
PortSetter setport(consolePort);
|
||||||
//PashortRect(&r);
|
|
||||||
|
|
||||||
for(short row = 0; row < rows; ++row)
|
for(short row = 0; row < rows; ++row)
|
||||||
{
|
{
|
||||||
|
@ -89,6 +87,7 @@ void Console::putch(char c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Console::ReadLine()
|
std::string Console::ReadLine()
|
||||||
{
|
{
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
class Console
|
class Console
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Console(GrafPtr port);
|
Console(GrafPtr port, Rect r);
|
||||||
void Draw();
|
void Draw();
|
||||||
void putch(char c);
|
void putch(char c);
|
||||||
std::string ReadLine();
|
std::string ReadLine();
|
||||||
|
|
99
App2/test.cc
99
App2/test.cc
|
@ -47,69 +47,25 @@ extern "C" ssize_t consolewrite(int fd, const void *buf, size_t count)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Rect r;
|
//GrafPort port;
|
||||||
unsigned char buf[256];
|
WindowPtr win;
|
||||||
//foo = bar;
|
|
||||||
r.top = r.left = 0;
|
|
||||||
r.bottom = 342;
|
|
||||||
r.right = 512;
|
|
||||||
//= { 0, 0, 342, 512 };
|
|
||||||
//Debugger();
|
|
||||||
GrafPort port;
|
|
||||||
InitGraf(&qd.thePort);
|
InitGraf(&qd.thePort);
|
||||||
InitFonts();
|
InitFonts();
|
||||||
OpenPort(&port);
|
InitWindows();
|
||||||
EraseRect(&r);
|
InitMenus();
|
||||||
#if 0
|
|
||||||
MoveTo(100,100);
|
Rect r;
|
||||||
/*buf[0] = 2;
|
SetRect(&r, qd.screenBits.bounds.left + 5, qd.screenBits.bounds.top + 45, qd.screenBits.bounds.right - 5, qd.screenBits.bounds.bottom -5);
|
||||||
buf[1] = 'H';
|
win = NewWindow(NULL, &r, (unsigned char*)"", true, 0, (WindowPtr)-1, false, 0);
|
||||||
buf[2] = 'W';*/
|
|
||||||
|
SetPort(win);
|
||||||
#if 0
|
EraseRect(&win->portRect);
|
||||||
sprintf((char*)&buf[1], "Hello, world: %d", 6*7);//6.0 * 7.0);
|
|
||||||
buf[0] = strlen((char*)&buf[1]);
|
|
||||||
#else
|
|
||||||
std::ostringstream out;
|
|
||||||
out << "Hello, world: " << 6*7;
|
|
||||||
std::string str = out.str();
|
|
||||||
buf[0] = str.size();
|
|
||||||
std::copy(str.begin(), str.end(), &buf[1]);
|
|
||||||
#endif
|
|
||||||
DrawString(buf);
|
|
||||||
|
|
||||||
/*try
|
|
||||||
{
|
|
||||||
foobar();
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
PaintRect(&r);
|
|
||||||
}*/
|
|
||||||
//SysBeep(20);
|
|
||||||
#endif
|
|
||||||
/*try
|
|
||||||
{
|
|
||||||
FillRect(&r,&qd.gray);
|
|
||||||
foobar();
|
|
||||||
PaintRect(&r);
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
EraseRect(&r);
|
|
||||||
}*/
|
|
||||||
//
|
|
||||||
//if(!std::malloc(32))
|
|
||||||
// PaintRect(&r);
|
|
||||||
new char[32];
|
new char[32];
|
||||||
Console console(&port);
|
Console console(win, win->portRect);
|
||||||
__write_hook = &consolewrite;
|
__write_hook = &consolewrite;
|
||||||
// console.putch('a');
|
|
||||||
// console.putch('b');
|
|
||||||
console.putch('x');
|
console.putch('x');
|
||||||
console.putch('a');
|
console.putch('a');
|
||||||
console.putch('b');
|
console.putch('b');
|
||||||
//new char[42];
|
|
||||||
console.putch('c');
|
console.putch('c');
|
||||||
console.putch('a');
|
console.putch('a');
|
||||||
console.putch('a');
|
console.putch('a');
|
||||||
|
@ -119,37 +75,42 @@ int main(int argc, char** argv)
|
||||||
console.putch('\n');
|
console.putch('\n');
|
||||||
|
|
||||||
std::cout << "Hello, world.\n";
|
std::cout << "Hello, world.\n";
|
||||||
//printf("Hello, world.\n");
|
printf("Hello, world.\n");
|
||||||
console.putch('a');
|
console.putch('a');
|
||||||
Console::currentInstance->putch('Y');
|
Console::currentInstance->putch('Y');
|
||||||
std::cout << "X\n";
|
|
||||||
|
/*std::cout << "X\n";
|
||||||
for(int i = 1; i <= 100; i++)
|
for(int i = 1; i <= 100; i++)
|
||||||
std::cout << "Hello, world: " << i << std::endl;
|
std::cout << "Hello, world: " << i << std::endl;
|
||||||
std::cout << std::flush;
|
std::cout << std::flush;
|
||||||
|
|
||||||
std::cout << "Say something: " << std::flush;
|
std::cout << "Say something: " << std::flush;*/
|
||||||
console.ReadLine();
|
printf("Say something: ");
|
||||||
|
fflush(stdout);
|
||||||
|
printf("You said: %s\n", console.ReadLine().c_str());
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
std::cout << "Exception speed test: " << std::flush;
|
//std::cout << "Exception speed test: " << std::flush;
|
||||||
|
printf("Exception speed test: "); fflush(stdout);
|
||||||
long start = TickCount();
|
long start = TickCount();
|
||||||
try { foobar(); } catch(...) {}
|
try { foobar(); } catch(...) {}
|
||||||
long end = TickCount();
|
long end = TickCount();
|
||||||
std::cout << (end-start)*1000 / 60.0 << " ms\n";
|
//std::cout << (end-start)*1000 / 60.0 << " ms\n";
|
||||||
|
printf("%g\n",(end-start)*1000 / 60.0);
|
||||||
}
|
}
|
||||||
std::cout << "Click mouse 10 times...\n";
|
//std::cout << "Click mouse 10 times...\n";
|
||||||
//console.Draw();
|
const int n = 3;
|
||||||
for(int i = 0; i < 10; i++)
|
printf("Click mouse %d times...\n", n);
|
||||||
|
for(int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
//InvertRect(&qd.screenBits.bounds);
|
|
||||||
while(!Button())
|
while(!Button())
|
||||||
;
|
;
|
||||||
while(Button())
|
while(Button())
|
||||||
;
|
;
|
||||||
std::cout << "Click #" << i + 1 << std::endl;
|
//std::cout << "Click #" << i + 1 << std::endl;
|
||||||
//console.Draw();
|
printf("Click #%d\n", i+1);
|
||||||
}
|
}
|
||||||
// something *= 7.0;
|
FlushEvents(everyEvent, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
project(Retro)
|
||||||
add_subdirectory(libretro)
|
add_subdirectory(libretro)
|
||||||
add_subdirectory(App2)
|
add_subdirectory(App2)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user