Jump to content

[SOLVED] Customization of UNIGINE Application


photo

Recommended Posts

Hello,

 

for shipping one of the projects I worked for, we needed to customize the application startup window. Goal is to modify the splash screen and window title+logo to fit our custom needs. Currently, there are only two ways (I have discovered so far). First is changing the application setting in the AppSystem-Class but as mentioned as in the documentation, the default configuration will be loaded first and any customizations afterwards. For that case the documentation links to the page to write your own custom App-class. But for this second way, not only the functions for rendering/updating needs to be modified, but all other virtual ones (Mouse, AppText e.g.). This implementation is perfect to integrate into other projects (like the samples shown for QT and SDL) but not for a simple modification of above mentioned use-case. Are there any other to improvements that can be made for the C++-Customization of the Application before startup?

 

Best

Christian

Link to comment

Hi Christian,

Have you tried something like this (seems to be enough for your case):

// AppSystemLogic.cpp

#include <UnigineSplash.h>
#include <UnigineApp.h>
#include <UnigineImage.h>

 // ...
using namespace Unigine;
int AppSystemLogic::init()
{
	// ...
	// define new transform for splash screen
	Unigine::Math::vec4 transform = Unigine::Math::vec4(1.0f, 1.0f, 0.0f, 0.0f);

	// get the splash and app instances (as they're designed as singletons)
	Unigine::Splash* splash = Unigine::Splash::get();
	Unigine::App* app = Unigine::App::get();

	// set a custom icon for the application window
	ImagePtr icon = Image::create("my_window_icon.png");
	app->setIcon(icon->getPixels2D(), icon->getWidth());

	// set a custom title for the application window
	app->setTitle("Custom Window Title");

	// set transform to the system and world splash screens
	splash->setSystemTransform(transform);
	splash->setWorldTransform(transform);

	// compute the aspect ratio to show corresponding texture
	float aspect_ratio = (float)app->getWidth() / (float)app->getHeight();
	
	// if the aspect ratio is 4:3 show these splash screens
	// during application and world load
	if (aspect_ratio < 1.5f) {
		splash->setSystem("splash_4x3_system.png");
		splash->setWorld("splash_4x3_world.png");
	}
	else {
		// if the aspect ratio is 16:9 show these splash screens
		// during application and world load
		splash->setSystem("splash_16x9_system.png");
		splash->setWorld("splash_16x9_world.png");
	}
	return 1;
}

Hope this helps!

Thanks!

  • Like 1
Link to comment

Hello fox,

 

thanks for the reply. This indeed solved the problem about the splashscreen. But the window title still remains unchanged until the AppSystemLogic-class is called and is therefor visible for 2-3 seconds.

 

Regards

Christian

Link to comment

Hi Christian,

You're welcome!

As for the window title, without a custom App class instance passed, the default title is set inside Engine::init() and therefore is displayed during the Engine initialization phase. So, I'm afraid there is no other simple option except for the custom App-class.

Best regards!

Link to comment

Hi fox,

2 hours ago, fox said:

 

As for the window title, without a custom App class instance passed, the default title is set inside Engine::init() and therefore is displayed during the Engine initialization phase. So, I'm afraid there is no other simple option except for the custom App-class.

 

not a problem that there isn't an easy out-of-the-box-solution. Thats why I am posting it to the suggestion forum. :) I am just wondering how the other users handle that topic when shipping their solution to the end user. Maybe if we can add an additional parameter to the bat file as a startup-configuration or just simply using the project name would be a better approach.

 

Best

Christian

Link to comment
  • 1 month later...
  • 2 months later...
  • silent changed the title to [SOLVED] Customization of UNIGINE Application
×
×
  • Create New...