Beispiel #1
2
void
Enemy::Attack(Character *c) {
    GUI gui;
    std::stringstream ss;
    int dmg;

    ss << "The " << this->descriptor << " " << this->name << " attacks ";
    ss << c->name;

    // The attack
    dmg = rand() % this->ATT - rand() % c->curDEF;
    if (dmg <= 0)
        ss << " but misses";
    else {
        dmg += rand() % (int)(this->STR) - rand() % c->curTOU;

        //The damage
        if (dmg <= 0)
            ss << " but it does no damage";
        else {
            ss << " and does " << dmg << " damage";
            c->curHP -= dmg;
        }
    }

    gui.AddMessage(ss.str());
}
Beispiel #2
0
GUIImage::GUIImage(const GUIImage& image_){
	
    if (image_.sdl_impl == 0) throw Error("Cannot form a GUIImage from bad image");
	SDL_Surface* temp = create_SDL_Surface(image_.getw(), image_.geth());
	if (!temp){
		throw Error("Could not copy GUIImage. Not enough memory.");
	}	
	sdl_impl = SDL_DisplayFormat(temp);
	if (!sdl_impl){
		throw Error("Could not copy GUIImage. Not enough memory.");
	}


    Uint32 colorkey = image_.sdl_impl->format->colorkey;

    Uint8 alpha = image_.sdl_impl->format->alpha;
    
    
    // First fill background with the clear color, then display and re-clear.
    SDL_FillRect(sdl_impl, 0, colorkey);
    
	display_image(image_.sdl_impl, sdl_impl, 0, 0, 1);
    if (image_.is_alpha /*|| alpha != 0*/) {
        //Set all pixels of color R 0, G 0xFF, B 0xFF to be transparent
        SDL_SetColorKey(sdl_impl, SDL_SRCCOLORKEY, colorkey);
    }
}
Beispiel #3
0
int main(int argc, char** argv) {

	GUI * realGUI;
	realGUI = new GUI(argc, argv);
	realGUI->start();

    /*realmachine * real;
    real = new realmachine;
    vm v(real, 0, "sample.prg");
   
    while (v.finish == false ){
        v.step();
    }

    //std::string s;
    //std::cin >> s;
    //word w("ch", s);
    //int a = w.value;
    //std::cout << w.value << std::endl << w.vchar() << std::endl;
    //w.value = a;
    //std::cout << w.value << std::endl << w.vchar() << std::endl;

    std::cout << "\n";
    std::cout << "VEIKIA\n";

    delete real;


    //std::cout << " "<< m.hexadimal() <<" " << a.vchar();*/
    
    
    return 0;
}
Beispiel #4
0
int main(int argc, char *argv[])
{
	ERModel* erModel = new ERModel();
	PresentationModel* presentationModel = new PresentationModel(erModel);

	if (argc == 1 || strcmp(argv[1], "guimode") == 0)
	{
		QApplication app(argc, argv);
		GUI* graphicalUI = new GUI(presentationModel);

		graphicalUI->setWindowTitle("Entity Relation Diagramming Tool");
		graphicalUI->show();
		return app.exec();
	}
	else if (argc > 1 && strcmp(argv[1], "textmode") == 0)
	{
		TextUI* textUI= new TextUI(presentationModel);

		textUI->displayMenu();

		delete textUI;
		delete presentationModel;
		delete erModel;
		return 0;
	}
}
Beispiel #5
0
void GUI::set_parent(const GUI& parent)
{
	this->parent = &const_cast<GUI&>(parent);
	// set position relative to parent (if parent set)
	set_position(parent.get_x(), parent.get_y());
	//set_visible (get_parent()->is_visible()); // if parent is visible child will also be visible
}                 
Beispiel #6
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    GUI w;
    w.show();
    return a.exec();
}
Beispiel #7
0
int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    GUI gui;
    gui.show();
    return app.exec();
}
Beispiel #8
0
//------------------------------------------------------------------------------
const Theme * Control::getTheme() const
{
    GUI * gui = getGUI();
    if (gui == nullptr)
        return nullptr;
    return &(gui->getTheme());
}
Beispiel #9
0
int GUI::set_parent(lua_State *L)
{
	luaL_checktype(L, 1, LUA_TTABLE);
	luaL_checkany(L, 2); // parent
	if(lua_istable(L, 2))
	{
	    lua_getfield(L, 2, "udata");
	    if(lua_isuserdata(L, -1))
	    {
		    GUI * parent = *static_cast<GUI **>(lua_touserdata(L, -1));	
		    lua_getfield(L, 1, "udata");
	        if(lua_isuserdata(L, -1))
	        {
		        GUI * gui = *static_cast<GUI **>(lua_touserdata(L, -1));
		        gui->set_parent(*parent); // set parent in (C++)
			    // set parent in (Lua)
		        lua_pushvalue(L, 2);
	  	        lua_setfield(L, 1, "parent");
	        }
	    }
	}
	if(lua_isnil(L, 2))
	{
		lua_getfield(L, 1, "udata");
		if(lua_isuserdata(L, -1))
		{
		    GUI * gui = *static_cast<GUI **>(lua_touserdata(L, -1));
		    gui->parent = nullptr; // set parent to nullptr (C++)
		}
		lua_pushvalue(L, 2);
		lua_setfield(L, 1, "parent"); // set parent to nil (Lua)
	}
	return 0;	
}	 
Beispiel #10
0
int GUI::sub(GUI &gui, int startCode, bool showSelf) {
	GfxMan.lockFrame();

	removeFocus();

	// Show the sub GUI
	if (startCode == 0)
		gui.show();
	hide();

	GfxMan.unlockFrame();

	// Run the sub GUI
	int code = gui.run(startCode);

	GfxMan.lockFrame();

	// Hide the sub GUI
	if (showSelf)
		show();
	gui.hide();

	// Update the mouse position
	removeFocus();
	updateMouse();

	GfxMan.unlockFrame();

	return code;
}
Beispiel #11
0
static void
save_file(GtkWidget *widget, gpointer user_data) 
{
	GUI* gptr = (GUI*) user_data;
	Window* w = gptr->get_window();
	Plane* p = gptr->get_plane();
	int width = atoi(gtk_entry_get_text((GtkEntry*)w->width_entry));
	int height = atoi(gtk_entry_get_text((GtkEntry*)w->height_entry));
	Plane plane(width, height);
	plane.up = p->up;
	plane.down = p->down;
	plane.left = p->left;
	plane.right = p->right;
	Renderer renderer("", gptr->get_rs()[gptr->get_rs_current()].get_function());
	renderer.set_plane(&plane);
	renderer.render();
	
	GError *error = NULL;

	GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data (
			plane.data,
			GDK_COLORSPACE_RGB,
			FALSE,
			8,
			plane.width,
			plane.height,
			plane.width*3,
			NULL,
			NULL);

	gdk_pixbuf_savev (pixbuf, "New.bmp", "bmp", NULL, NULL, &error); 
	g_object_unref(pixbuf);
}
void MainWindow::clienteAceptado()
{
    qDebug("Nice");
    this->close();
    GUI *gui = new GUI(NULL,socket);
    gui->show();
}
Beispiel #13
0
int main()
{
	RenderWindow window(VideoMode(1280, 720), "Platformer");
	View view(Vector2f(0, 0), Vector2f(1280, 720)); //These numbers can be scaled to zoom it out
	window.setFramerateLimit(60);
	GUI* CurrentGUI = new GUI("menugui.txt", &window);
	CurrentGUI->SetCurrentGUI(CurrentGUI); //this line is so weird
	GUI* TestGUI = CurrentGUI;
	Clock clock;
	while (window.isOpen())
	{
		if (CurrentGUI != TestGUI)
		{
			cout << "New GUI in the main loop.\n";
			TestGUI = CurrentGUI;
		}
		if (clock.getElapsedTime().asSeconds() > 2)
		{
			cout << "CurrentGUI Address = " << CurrentGUI << endl;
			cout << "CurrentGUI name = " << CurrentGUI->GUIFileName << endl;

			clock.restart();
		}
		window.clear(Color::White);
		Event event;
		/*while (window.pollEvent(event)) //If theres any event that is supposed to close the window, do that and deallocate everything.
		{ 
			if (event.type == Event::Closed)
			{
				cout << "Closing...\n";
				window.close();
				cout << "Successfully closed window.\n";
				return 0;
			}
			else if (event.type == sf::Event::MouseWheelMoved)
			{
				if (event.mouseWheel.delta > 0)
				{
					view.zoom(0.7f);
					cout << "Zooming in... \n";
				}
				else if (event.mouseWheel.delta < 0)
				{
					view.zoom(1.3f);
					cout << "Zooming out... \n";
				}
			}
		} */
		if (Keyboard::isKeyPressed(Keyboard::Escape))
		{
			window.close();
		}
		window.setView(view);
		CurrentGUI->Update();
		view.setCenter(window.getSize().x / 2, window.getSize().y / 2);
		window.display();
	}

	return 0;
} 
Beispiel #14
0
int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    QDir::setCurrent(QCoreApplication::applicationDirPath());
    GUI w;
    w.show();

    return a.exec();
}
Beispiel #15
0
void Engine::Init()
{
	GUI gui;
	gui.Init();

	Effect effect;
	effect.Init();
}
Beispiel #16
0
int main(int, char**){
	GOOGLE_PROTOBUF_VERIFY_VERSION;

	GUI gui;
	gui.init();

    return 0;
}
Beispiel #17
0
void GUI::hide_all()
{
	for (int i = 0; i < Factory::get_gui_factory()->get_size(); i++) 
	{
		GUI * gui = static_cast<GUI *>(Factory::get_gui_factory()->get_object(i));
		gui->hide();
	}	
}
Beispiel #18
0
int main( int argc, char **argv ) {
	QApplication app( argc, argv );

	GUI *g = new GUI();
	g->show();
	
	return app.exec();
}
Beispiel #19
0
int main(int argc, char *argv[])
{

#ifdef HAS_GUI

    if (argc > 1){
    	// using terminal mode
    	if (argc < 2){
            printf("Usage: %s input _file\n", argv[0]);
    		exit(1);
    	}
    	else {
            TEMP_SCHEME* RunEngine = new TEMP_SCHEME(argc, argv);
    		RunEngine->evaluation();
    		return(0);
    	}
    }
    else {			// using GUI
    	QApplication app(argc, argv);
    	app.setOrganizationName(ORGANIZATION);
    	app.setApplicationName(NAME);
    	app.setApplicationVersion(VERSION);
/*
        QFile stylesheetfile(":/css/stylesheet.css");
        if (stylesheetfile.open(QFile::ReadOnly)){
            app.setStyleSheet(stylesheetfile.readAll());
            stylesheetfile.close();
        }
*/
    	QSplashScreen *splash = new QSplashScreen;
		splash->setPixmap(QPixmap(":/libel.png"));
		splash->show();
		splash->showMessage(app.organizationName());
		QIcon windowIcon(":/libel.png");

    	GUI gui;
    	gui.setWindowIcon(windowIcon);

        QTimer::singleShot(1000, splash, SLOT(close()));
        QTimer::singleShot(1000, &gui, SLOT(showMaximized()));

    	return app.exec();
    }
#else
    if (argc > 1){
        	// using terminal mode
        	if (argc < 2){
        		printf("Usage: %s input_file\n", argv[0]);
        		exit(1);
        	}
        	else {
                TEMP_SCHEME* RunEngine = new TEMP_SCHEME(argc, argv);
        		RunEngine->evaluation();
        		return(0);
        	}
        }
#endif
}
void mouseCallback(int event, int x, int y, int flags, void* userdata)
{
    GUI* gui = static_cast<GUI*>(userdata);

    double px = (double)x / gui->image.image->getRGBImage().cols;
    double py = (double)y / gui->image.image->getRGBImage().rows;

    if (event == cv::EVENT_LBUTTONDOWN && gui->selected_type == "exclude")
    {
        gui->image.excluded = true;
        std::cout << "Excluding image" << std::endl;
        gui->image_changed = true;
        gui->redraw();
    }
    else if (event == cv::EVENT_LBUTTONDOWN && gui->selected_type.size() > 5 && gui->selected_type.substr(0, 5) == "area:")
    {
        gui->image.area_name = gui->selected_type.substr(5);
        std::cout << "Setting area to '" << gui->image.area_name << "'" << std::endl;
        gui->image_changed = true;
        gui->redraw();
    }
    else if (event == cv::EVENT_LBUTTONDOWN || event == cv::EVENT_RBUTTONDOWN)
    {
//        std::cout << px << ", " << py << std::endl;

        std::vector<Annotation>::iterator it_clicked = gui->image.annotations.end();

        // Loop over all annotations and check whether we have clicked one
        for (std::vector<Annotation>::iterator it = gui->image.annotations.begin(); it != gui->image.annotations.end(); ++it)
        {
            Annotation& a = *it;

            int a_x = a.px * gui->image.image->getRGBImage().cols;
            int a_y = a.py * gui->image.image->getRGBImage().rows;

            if (x > a_x - gui->CIRCLE_RADIUS && x < a_x + gui->CIRCLE_RADIUS && y > a_y - gui->CIRCLE_RADIUS && y < a_y + gui->CIRCLE_RADIUS)
            {
                it_clicked = it;
                break;
            }
        }

        if (it_clicked != gui->image.annotations.end() && event == cv::EVENT_RBUTTONDOWN)
        {
            gui->image.annotations.erase(it_clicked);
            gui->image_changed = true;
        }

        if (it_clicked == gui->image.annotations.end() && event == cv::EVENT_LBUTTONDOWN && !gui->selected_type.empty())
        {
            gui->image.annotations.push_back(Annotation(gui->selected_type, px, py));
            gui->types.insert(gui->selected_type);
            gui->image_changed = true;
        }

        gui->redraw();
    }
}
Beispiel #21
0
void ModalEventPump::operator()()
{
    GUI* gui = GUI::GetGUI();
    EventPumpState& state = State();
    while (!Done()) {
        gui->HandleSystemEvents();
        LoopBody(gui, state, true, true);
    }
}
Beispiel #22
0
void GUI:: set_visible(bool visible) // shown or hidden
{ 
	this->visible = visible;
	for(int i = 0; i < get_children().size(); i++)
	{
		GUI * child = get_children()[i];
		child->set_visible (visible); // set child visibility to the same as parent
	}
}
int main(int argc, char** argv)
{
    std::string path = ".";
    if (argc > 1)
        path = argv[1];

    GUI gui;
    return gui.run(path);
}
Beispiel #24
0
//------------------------------------------------------------------------------
void Control::beginCapture()
{
	GUI * gui = getGUI();
	if (gui)
	{
		gui->setCapture(this);
		setControlFlag(TGUI_CF_CAPTURED, true);
	}
}
Beispiel #25
0
void GUI::set_relative_position(double x, double y) // set child position relative to the parent
{
	GUI * parent = get_parent();
	if(parent != nullptr) 
	{
        this->x = parent->get_x() + x;
        this->y = parent->get_y() + y;
	}
}
Beispiel #26
0
void NWNEngine::mainMenuLoop() {
	playMenuMusic();

	// Start sound
	playSound("gui_prompt", Sound::kSoundTypeSFX);

	// Create and fade in the legal billboard
	Legal *legal = new Legal;

	Console console;
	Module module(*_version, console);

	_scriptFuncs->setModule(&module);
	console.setModule(&module);

	while (!EventMan.quitRequested()) {
		GUI *mainMenu = new MainMenu(module);

		EventMan.flushEvents();
		if (legal) {
			// Fade in, show and fade out the legal billboard
			legal->fadeIn();
			mainMenu->show();
			legal->show();

			delete legal;
			legal = 0;
		} else
			mainMenu->show();

		mainMenu->run();
		mainMenu->hide();

		delete mainMenu;

		if (EventMan.quitRequested())
			break;

		stopMenuMusic();

		module.run();
		if (EventMan.quitRequested())
			break;

		playMenuMusic();
		console.hide();
		module.clear();
	}

	_scriptFuncs->setModule(0);
	console.setModule();

	stopMenuMusic();

	delete legal;
}
Beispiel #27
0
static void
da_allocate_callback(GtkWidget    *widget,
		GdkRectangle *allocation,
		gpointer      user_data)
{
  	GUI* gptr = (GUI*) user_data;
	Plane* plane = gptr->get_plane();
	plane->resize(allocation->width, allocation->height);
	gptr->render();
}
Beispiel #28
0
double GUI::get_relative_y() const
{
	GUI * parent = get_parent();
    if(parent == nullptr) 
	{
		Logger("GUI has no parent");
		return get_y();
	}
	return get_position().y - parent->get_position().y;	
}
Beispiel #29
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QGuiApplication::setApplicationDisplayName(GUI::tr("ICP - Reversi"));
    GUI g;

    g.show();

    return app.exec();
}
void* run_ui(void* ptr)
{
	GUI* interface = (GUI*)ptr;
	interface->run();
	pthread_exit(0);
	return 0;
}