Exemple #1
0
void ToolBar::buttonInit(unsigned int ix, ToolboxButtonIndex TBI, 
                    const char* file_path, const wchar_t* text)
{
    ITexture* img;
    img = Editor::loadImg(file_path);
    m_buttons[ix] = m_bar->addButton(TBI, 0, text, img, 0, false, true);
    m_buttons[ix]->setMaxSize(dimension2du(40, 40));
    m_buttons[ix]->setMinSize(dimension2du(40, 40));
} // buttonInit
Exemple #2
0
// ----------------------------------------------------------------------------
void ToolBar::init()
{
    Editor* editor = Editor::getEditor();
    path icons = editor->getIconsLoc();
    m_bar      = editor->getGUIEnv()->addToolBar();
    m_bar->setMinSize(dimension2du(0,50));

    buttonInit(0,  TBI_NEW,         (icons + "new.png").c_str(),      _(L"New (ctrl+n)"));
    buttonInit(1,  TBI_OPEN,        (icons + "open.png").c_str(),     _(L"Open (ctrl+o)"));
    buttonInit(2,  TBI_SAVE,        (icons + "save.png").c_str(),     _(L"Save (ctrl+s)"));
    buttonInit(3,  TBI_EXPORT ,     (icons + "save_as.png").c_str(),  _(L"Export (ctrl+shift+s)"));
    buttonInit(4,  TBI_UNDO,        (icons + "undo.png").c_str(),     _(L"Undo (ctrl+z)"));
    buttonInit(5,  TBI_REDO,        (icons + "redo.png").c_str(),     _(L"Redo (ctrl+y)"));
    buttonInit(6,  TBI_SELECT,      (icons + "select.png").c_str(),   _(L"Select (shift+a)"));
    buttonInit(7,  TBI_MOVE,        (icons + "move.png").c_str(),     _(L"Move (shift+g)"));
    buttonInit(8,  TBI_ROTATE,      (icons + "rotate.png").c_str(),   _(L"Rotate (shift+r)"));
    buttonInit(9,  TBI_SCALE,       (icons + "scale.png").c_str(),    _(L"Scale (shift+s)"));
    buttonInit(10, TBI_DELETE,      (icons + "delete.png").c_str(),   _(L"Delete (del)"));
    buttonInit(11, TBI_CAM,         (icons + "cam1.png").c_str(),     _(L"Toggle camera mode (c)"));
    buttonInit(12, TBI_RECAM,       (icons + "cam2.png").c_str(),     _(L"Restore camera state (NUM1)"));
    buttonInit(13, TBI_DRIVELINE,   (icons + "spline.png").c_str(),   _(L"Select DriveLine (r)"));  
    buttonInit(14, TBI_HIDE_TERRAIN,(icons + "ht.png").c_str(),       _(L"Hide terrain (t)"));
    buttonInit(15, TBI_MUSIC,       (icons + "music.png").c_str(),    _(L"Music"));
    buttonInit(16, TBI_TRY,         (icons + "try.png").c_str(),      _(L"Try your track"));
    buttonInit(17, TBI_EXIT,        (icons + "exit.png").c_str(),     _(L"Quit (esc)"));

    reallocate();

} // init
Exemple #3
0
// ----------------------------------------------------------------------------
void Editor::dataDirLocDlg()
{
    IGUIFileOpenDialog* ofd = m_gui_env->addFileOpenDialog(
        L"Pls. select data directory (folder containing textures, tracks, etc.):",
        true, 0, -1, true);
    ofd->setMinSize(dimension2du(600, 512));
    ofd->setRelativePosition(position2di(m_screen_size.Width / 2 - 300, 100));
} // dataDirLocDlg
Exemple #4
0
CNrpVideoConfig::CNrpVideoConfig() : INrpConfig( CLASS_VIDEOCONFIG, CLASS_VIDEOCONFIG) 
{		
	RegProperty<dimension2du>( SCREEN_SIZE, dimension2du( 1024, 660 ) );//высота экрана
	RegProperty<bool>( FULLSCREEN, false );		//полноэкранный режим
	RegProperty<bool>( USE_SHADOWS, false );		//отображение теней
	RegProperty<bool>( VSYNC, false );	//вертикальная синх.

	Load( "config/video.ini" );
}
Exemple #5
0
// ----------------------------------------------------------------------------
bool Editor::init()
{
    m_maps_path         = NULL;
    m_music_loc         = NULL;
    m_indicator         = NULL;
    m_valid_data_dir    = false;
    m_exe_loc           = "";
    m_toolbar           = NULL;
    m_toolbox           = NULL;
    m_rcs               = NULL;
    m_tex_sel           = NULL;
    m_indicator         = NULL;
    m_viewport          = NULL;
    m_rcs               = NULL;
    m_font              = NULL;
    m_new_dialog_wndw   = NULL;

    m_screen_size = dimension2du(10, 10);

    IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL);
    m_screen_size = nulldevice->getVideoModeList()->getDesktopResolution();
    readConfigFile(nulldevice->getFileSystem());
    nulldevice->drop();

    m_device = createDevice(EDT_OPENGL, m_screen_size, 16, false, false, true);
    if (!m_device) return false;

    m_device->setResizable(true);
    m_device->setWindowCaption(L"SuperTuxKart Track Editor Beta v0.03");

    if (m_screen_size.Width < 20 || m_screen_size.Height < 20)
        m_device->maximizeWindow();

    m_video_driver  = m_device->getVideoDriver();
    m_scene_manager = m_device->getSceneManager();
    m_gui_env       = m_device->getGUIEnvironment();

    m_screen_size   = m_video_driver->getScreenSize();
    m_def_wd        = m_device->getFileSystem()->getWorkingDirectory();

    // lights
    m_scene_manager->setAmbientLight(SColorf(0.3f, 0.3f, 0.3f, 1.0f));
    ILightSceneNode* l = m_scene_manager->addLightSceneNode(0, vector3df(0, 1, 0),
                                              SColorf(1.0f, 1.0f, 1.0f), 500, -1);
    l->setLightType(ELT_DIRECTIONAL);
    l->setPosition(vector3df(0,
        1, 0));

    m_device->setEventReceiver(this);

    if (!isValidDataLoc()) dataDirLocDlg();

    return true;
} // init
Exemple #6
0
// ----------------------------------------------------------------------------
ITexture* Terrain::createSplattingImg()
{
    IVideoDriver* vd = Editor::getEditor()->getVideoDriver();

    auto img = autoDropped(
        vd->createImage(ECF_A8R8G8B8, dimension2du(SPIMG_X, SPIMG_Y)));

    for (u32 i = 0; i < SPIMG_X; i++)
        for (u32 j = 0; j < SPIMG_Y; j++)
            img->setPixel(i, j, SColor(255, 0, 0, 0));

    return vd->addTexture("splatt.png", img.get());
} // initSplattingImg
Exemple #7
0
//-----------------------------------------------------------------------------
//                           _ c r e a t e D e v i c e
//-----------------------------------------------------------------------------
static IrrlichtDevice* _createDevice()
{
    m_eventReceiver = new EventReceiver();
    SIrrlichtCreationParameters cp;
    cp.DriverType = m_driverType;
    cp.WindowSize = dimension2du(WINDOW_SIZE_X,WINDOW_SIZE_Y);
    cp.Bits = DEVICE_BPP;
    cp.Fullscreen = false;
    cp.Vsync = true;
    cp.Stencilbuffer = false;
    cp.AntiAlias = 4;
    cp.EventReceiver = m_eventReceiver;
    cp.WindowId = 0;

    return createDeviceEx(cp);
}
Exemple #8
0
Game::Game() : 
enemyField(ENEMY_FIELD_SIZE),
	fighterLine(line3df(FIGHTER_LINE_SIZE)), 
	enemies(new EnemyHolder()), 
	fighter(new Fighter()), 
	rockets(new RocketHolder()), 
	gui(new GUI()),
	effects(new Effect()),
	texManager(new TextureManager()),
	engine(new Irrlicht(L"Space Battle", dimension2du(WINDOW_WIDTH, WINDOW_HEIGHT))), 
	state(MENU), 
	sound(createIrrKlangDevice()), 
	score(0), 
	soundPlay(true)
{
	srand(time(NULL));
}
Exemple #9
0
// ----------------------------------------------------------------------------
void Editor::readConfigFile(IFileSystem* file_system)
{
    IXMLReader* xml_reader = file_system->createXMLReader(path(PHYSFS_getBaseDir())
                                                                    + "config.xml");

    if (!xml_reader)
    {
        path dir = PHYSFS_getUserDir();
        m_config_loc = dir + "/.stk-te";
        xml_reader = file_system->createXMLReader(m_config_loc + "/config.xml");
        if (!xml_reader)
        {
            PHYSFS_setWriteDir(dir.c_str());
            PHYSFS_mkdir(".stk-te");
            return;
        }
    }
    else m_config_loc = PHYSFS_getBaseDir();

    const stringw node_name(L"data_dir");
    const stringw res(L"res");
    const stringw exe(L"exe");
    while (xml_reader->read())
    {
        if (xml_reader->getNodeType() == EXN_ELEMENT)
        {
            if (res.equals_ignore_case(xml_reader->getNodeName()))
            {
                m_screen_size = dimension2du(
                    atol(((stringc)xml_reader->getAttributeValueSafe(L"x")).c_str()),
                    atol(((stringc)xml_reader->getAttributeValueSafe(L"y")).c_str()));
            }
            else  if (node_name.equals_ignore_case(xml_reader->getNodeName()))
            {
                m_data_loc = xml_reader->getAttributeValueSafe(L"path");
                m_icons_loc = m_data_loc + "editor/icons/";
            }
            else if (exe.equals_ignore_case(xml_reader->getNodeName()))
            {
                m_exe_loc = xml_reader->getAttributeValueSafe(L"path");
            }
        }
    }
    xml_reader->drop();
} // readConfigFile
Exemple #10
0
//! Creates a software image from part of a texture.
IImage* CNullDriver::createImage(ITexture* texture, const position2d<s32>& pos, const dimension2d<u32>& size)
{
	if ((pos==position2di(0,0)) && (size == texture->getSize()))
	{
		IImage* image = new CImage(texture->getColorFormat(), size, texture->lock(ETLM_READ_ONLY), false);
		texture->unlock();
		return image;
	}
	else
	{
		// make sure to avoid buffer overruns
		// make the vector a separate variable for g++ 3.x
		const vector2d<u32> leftUpper(clamp(static_cast<u32>(pos.X), 0u, texture->getSize().Width),
					clamp(static_cast<u32>(pos.Y), 0u, texture->getSize().Height));
		const rectangle<u32> clamped(leftUpper,
					dimension2du(clamp(static_cast<u32>(size.Width), 0u, texture->getSize().Width),
					clamp(static_cast<u32>(size.Height), 0u, texture->getSize().Height)));
		if (!clamped.isValid())
			return 0;
		u8* src = static_cast<u8*>(texture->lock(ETLM_READ_ONLY));
		if (!src)
			return 0;
		IImage* image = new CImage(texture->getColorFormat(), clamped.getSize());
		u8* dst = static_cast<u8*>(image->lock());
		src += clamped.UpperLeftCorner.Y * texture->getPitch() + image->getBytesPerPixel() * clamped.UpperLeftCorner.X;
		for (u32 i=0; i<clamped.getHeight(); ++i)
		{
			CColorConverter::convert_viaFormat(src, texture->getColorFormat(), clamped.getWidth(), dst, image->getColorFormat());
			src += texture->getPitch();
			dst += image->getPitch();
		}
		image->unlock();
		texture->unlock();
		return image;
	}
}
Exemple #11
0
int main(int argc, char* argv[]) {
#ifdef _WIN32
	WORD wVersionRequested;
	WSADATA wsaData;
	wVersionRequested = MAKEWORD(2, 2);
	WSAStartup(wVersionRequested, &wsaData);
	evthread_use_windows_threads();
#else
	evthread_use_pthreads();
#endif //_WIN32
	ygo::Game _game;
	ygo::mainGame = &_game;
	_game.window_size = dimension2du(1024, 640);
	if(!ygo::mainGame->Initialize())
		return 0;

	for(int i = 1; i < argc; ++i) {
		/*command line args:
		 * -j: join host (host info from system.conf)
		 * -f: forced join host (host info from system.conf, immediately set ready)
		 * -d: deck edit
		 * -r: replay */
		if(argv[i][0] == '-' && argv[i][1] == 'e') {
			ygo::dataManager.LoadDB(&argv[i][2]);
		} else if(!strcmp(argv[i], "-j") || !strcmp(argv[i], "-f") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-r") || !strcmp(argv[i], "-s")) {
			exit_on_return = true;
			irr::SEvent event;
			event.EventType = irr::EET_GUI_EVENT;
			event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED;
			if(!strcmp(argv[i], "-j")) {
				ygo::mainGame->wMainMenu->setVisible(false);
				ygo::mainGame->menuHandler.OnJoinHost();
			} else if(!strcmp(argv[i], "-f")) {
				ygo::mainGame->wMainMenu->setVisible(false);
				ygo::mainGame->menuHandler.OnJoinHost(true);
			} else if(!strcmp(argv[i], "-d")) {
				event.GUIEvent.Caller = ygo::mainGame->btnDeckEdit;
				ygo::mainGame->device->postEventFromUser(event);
			} else if(!strcmp(argv[i], "-r")) {
				event.GUIEvent.Caller = ygo::mainGame->btnReplayMode;
				ygo::mainGame->device->postEventFromUser(event);
				ygo::mainGame->lstReplayList->setSelected(ygo::mainGame->gameConf.lastreplay);
				if(ygo::mainGame->lstReplayList->getSelected() != -1){
					event.GUIEvent.Caller = ygo::mainGame->btnLoadReplay;
					ygo::mainGame->device->postEventFromUser(event);
				}
			} else if(!strcmp(argv[i], "-s")) {
				event.GUIEvent.Caller = ygo::mainGame->btnServerMode;
				ygo::mainGame->device->postEventFromUser(event);
				ygo::mainGame->lstSinglePlayList->setSelected(ygo::mainGame->gameConf.lastpuzzle);
				if(ygo::mainGame->lstSinglePlayList->getSelected() != -1){
					event.GUIEvent.Caller = ygo::mainGame->btnLoadSinglePlay;
					ygo::mainGame->device->postEventFromUser(event);
				}
			}

		}
	}
	ygo::mainGame->MainLoop();
#ifdef _WIN32
	WSACleanup();
#else

#endif //_WIN32
	return EXIT_SUCCESS;
}
Exemple #12
0
// ----------------------------------------------------------------------------
void RoadPanel::reallocate(dimension2du ss)
{
    m_wndw->setMinSize(dimension2du(250, ss.Height - 50));
} // reallocate
		//! Returns JPG image
		IImage* SharedImageLoaderJpg::createImage(io::IReadFile* file)
		{
			IRR_ASSERT(file);

			s32 jfif = 0;
			file->seek(6);
			file->read(&jfif, sizeof(s32));

			bool isJpegFile = jfif == 0x4a464946 || jfif == 0x4649464a;

			IRR_ASSERT(isJpegFile);

			file->seek(0);

			u8 **rowPtr = 0;
			u8* input = new u8[file->getSize()];
			file->read(input, file->getSize());

			// allocate and initialize JPEG decompression object
			struct jpeg_decompress_struct cinfo;

			struct SJpgErrorMgr jerr;

			//We have to set up the error handler first, in case the initialization
			//step fails.  (Unlikely, but it could happen if you are out of memory.)
			//This routine fills in the contents of struct jerr, and returns jerr's
			//address which we place into the link field in cinfo.

			cinfo.err = jpeg_std_error(&jerr.pub);

			cinfo.err->error_exit = StaticJpgExtension::errorExit;
			cinfo.err->output_message = StaticJpgExtension::outputMessage;

			// compatibility fudge:
			// we need to use setjmp/longjmp for error handling as gcc-linux
			// crashes when throwing within external c code
			if (setjmp(jerr.setjmp_buffer))
			{
				// If we get here, the JPEG code has signaled an error.
				// We need to clean up the JPEG object and return.

				jpeg_destroy_decompress(&cinfo);

				delete[] input;

				// if the row pointer was created, we delete it.
				if (rowPtr)
				{
					delete[] rowPtr;
				}

				IRR_ASSERT(false);
			}

			// Now we can initialize the JPEG decompression object.
			jpeg_create_decompress(&cinfo);

			// specify data source
			jpeg_source_mgr jsrc;

			// Set up data pointer
			jsrc.bytes_in_buffer = file->getSize();
			jsrc.next_input_byte = (JOCTET*) input;
			cinfo.src = &jsrc;

			jsrc.init_source = StaticJpgExtension::initSource;
			jsrc.fill_input_buffer = StaticJpgExtension::fillInputBuffer;
			jsrc.skip_input_data = StaticJpgExtension::skipInputData;
			jsrc.resync_to_restart = jpeg_resync_to_restart;
			jsrc.term_source = StaticJpgExtension::termSource;

			// Decodes JPG input from whatever source
			// Does everything AFTER jpeg_create_decompress
			// and BEFORE jpeg_destroy_decompress
			// Caller is responsible for arranging these + setting up cinfo

			// read file parameters with jpeg_read_header()
			jpeg_read_header(&cinfo, TRUE);

			bool useCMYK = false;
			if (cinfo.jpeg_color_space == JCS_CMYK)
			{
				cinfo.out_color_space = JCS_CMYK;
				cinfo.out_color_components = 4;
				useCMYK = true;
			}
			else
			{
				cinfo.out_color_space = JCS_RGB;
				cinfo.out_color_components = 3;
			}
			cinfo.do_fancy_upsampling = FALSE;

			// Start decompressor
			jpeg_start_decompress(&cinfo);

			// Get image data
			u16 rowspan = cinfo.image_width * cinfo.out_color_components;
			u32 width = cinfo.image_width;
			u32 height = cinfo.image_height;

			// Allocate memory for buffer
			u8* output = new u8[rowspan * height];

			// Here we use the library's state variable cinfo.output_scanline as the
			// loop counter, so that we don't have to keep track ourselves.
			// Create array of row pointers for lib
			rowPtr = new u8*[height];

			for (u32 i = 0; i < height; i++)
			{
				rowPtr[i] = &output[i * rowspan];
			}

			u32 rowsRead = 0;

			while (cinfo.output_scanline < cinfo.output_height)
			{
				rowsRead += jpeg_read_scanlines(&cinfo, &rowPtr[rowsRead],
						cinfo.output_height - rowsRead);
			}

			delete[] rowPtr;

			// Finish decompression
			jpeg_finish_decompress(&cinfo);

			// Release JPEG decompression object
			// This is an important step since it will release a good deal of memory.
			jpeg_destroy_decompress(&cinfo);

			// convert image
			IImage* result = 0;
			if (useCMYK)
			{
				result = IImage::createEmptyImage(ECF_R8G8B8,
						dimension2du(width, height));

				const u32 size = 3 * width * height;
				u8* data = (u8*) result->lock();
				if (data)
				{
					for (u32 i = 0, j = 0; i < size; i += 3, j += 4)
					{
						// Also works without K, but has more contrast with K multiplied in
						//				data[i+0] = output[j+2];
						//				data[i+1] = output[j+1];
						//				data[i+2] = output[j+0];
						data[i + 0] = (char) (output[j + 2]
								* (output[j + 3] / 255.f));
						data[i + 1] = (char) (output[j + 1]
								* (output[j + 3] / 255.f));
						data[i + 2] = (char) (output[j + 0]
								* (output[j + 3] / 255.f));
					}
				}
				result->unlock();
				delete[] output;
			}
			else
			{
				result = IImage::createRawImage(ECF_R8G8B8,
						dimension2du(width, height), output);
			}

			delete[] input;

			return result;
		}
Exemple #14
0
dimension2du CNullDriver::getMaxTextureSize() const
{
	return dimension2du(0x10000,0x10000); // maybe large enough
}