MainWindow::MainWindow(HINSTANCE instance) : m_inDialog(false), m_parent(nullptr), m_instance(instance), m_emptyLink(nullptr) { enableLogging(settings::settings()[L"general"][L"log"].asNumber() != 0); LOG(L"creating MainWindow"); registerWindowClass(instance, loadString(instance, IDC_LAUNCHGRID).c_str()); m_wnd = createMainWindow(); createFonts(); LOG(L"creating static controls"); m_titleLabel = CreateWindow(L"STATIC", loadString(instance, IDS_APP_TITLE).c_str(), WS_CHILD | WS_VISIBLE, 8, 4, 120, 30, m_wnd, nullptr, instance, nullptr); SendMessage(m_titleLabel, WM_SETFONT, (WPARAM)m_titleFont, 0); m_menu = CreateWindow(L"BUTTON", L"Menu", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 240 - 8 - 24, 4, 24, 24, m_wnd, nullptr, instance, nullptr); SetWindowLong(m_menu, GWL_ID, IDC_MENU); createControls(); LOG(L"showing window"); ShowWindow(m_wnd, settings::settings()[L"general"][L"bottomWindow"].asNumber() ? SW_SHOWNOACTIVATE : SW_SHOW); if (settings::settings()[L"general"][L"bottomWindow"].asNumber()) { LOG(L"moving window to background"); SetWindowPos(m_wnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } UpdateWindow(m_wnd); }
void UIRichTextArea::createFontChars() { for (CONTENTS_ITER iter = _contents.begin(); iter != _contents.end(); ++iter) { stUIRichString & content = *iter; if (content.stringType == stUIRichString::UI_STRING_TYPE_FONT) { createFonts(cc_utf16_from_utf8(content.content.c_str()),content.x,content.y,content.color,content.fontSize); } else if (content.stringType == stUIRichString::UI_STRING_TYPE_IMG) { createImage(content.content.c_str(),content.x,content.y,content.width,content.height); } } }
bool WaitingForYou::forePlay() { // call parent Buddha::Game::forePlay(); // input handler setInputMessageHandler(new InputMessageHandler); // create modules if (!createModules()) { return false; } Record(Buddha::Logger::getInstancePtr()->getPath()); // if (!setViewport()) { return false; } // // DragAcceptFiles(_hwnd, true); // if (!initGeometry()) { return false; } // if (!createFonts()) { return false; } // // _camera = new Euclid::Camera; _camera->setPosition(Vec3(0.0f, 0.0f, 50.0f)); // _cameraController = new Euclid::CameraControllerThirdPerson(_camera); setProcess(Buddha::eProcess_CreateModules); // return true; }
bool WaitingForYou::forePlay() { // call parent Buddha::Game::forePlay(); // input handler setInputMessageHandler(new InputMessageHandler); // create modules if (!createModules()) { return false; } Record(Buddha::Logger::getInstancePtr()->getPath()); // if (!setViewport()) { return false; } // DragAcceptFiles(_hwnd, true); // if (!initGeometry()) { return false; } // if (!createFonts()) { return false; } setProcess(Buddha::eProcess_CreateModules); // return true; }
void SAppBase::init() { // setup logging dlog.add(new dlogprinterfile(Path::localSettings(Path("log.txt")))); derr.add(new dlogprinterfile(Path::localSettings(Path("errors.txt")))); loadConfig("options.ini", true); m_options = &config("options.ini"); loadConfig("ui.ini", true); m_ui = &config("ui.ini"); loadConfig("materials.ini"); m_materials = &config("materials.ini"); std::string uistylesConfigName = m_options->get("UI", "StyleFile", std::string("uistyles.ini")); loadConfig(uistylesConfigName); m_uiStyles = &config(uistylesConfigName); // Heap debugging if (hasCmdLineOption("heapdebug")) { #if IS_MSVC int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; _CrtSetDbgFlag( tmpFlag ); #else throw("Heap debugging is only enabled in MSVC builds."); #endif } // create log dlog << m_appName << " - " << getCPUVendorID() << " " << getCPUTicksPerSecond() / 1000000.0f << " Mhz" << dlog.endl; // get default window icon, if available // tbd:mingw: fix //HICON groupIcon = LoadIcon(GetModuleHandle(0), "APP"); // Register the window class. WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, StaticMsgProc, 0L, sizeof(LONG), GetModuleHandle(NULL), /*groupIcon*/0, LoadCursor(0, IDC_ARROW), NULL, NULL, m_appName.c_str(), NULL }; RegisterClassEx( &wc ); //FreeResource(groupIcon); // Create the application's window. m_hWnd = CreateWindow( m_appName.c_str(), m_appName.c_str(), WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, GetDesktopWindow(), NULL, wc.hInstance, NULL ); if (!m_hWnd) throwf("Couldn't create a window."); // setup device bool windowed = hasCmdLineOption("w"); Point2i fullscreenSize = options().get("Render", "FullscreenSize", Point2i(1024, 768)); Point2i windowedSize = options().get("Render", "WindowedSize", Point2i(640, 480)); D3D().newDevice( windowed, fullscreenSize.x, fullscreenSize.y, windowedSize.x, windowedSize.y ); createFonts(); // create dialog mgr m_pDlgMgrSingleton = new SDialogMgr; if (!Input().create(GetModuleHandle(NULL))) throwf("Couldn't create input"); if (!Input().createMouse(m_hWnd)) throwf("Couldn't create mouse"); // setup ui DialogMgr().create(); m_textureAnimation = new TextureAnimationManager("animations.ini"); m_particles = new ParticleFactory("particles.ini", m_textureAnimation->set("particles")); m_spriteFX = new SpriteFXFactory("spritefx.ini"); timer().restart(); m_updateLoopFreq = options().get("Game", "UpdateLoopFreq", 0.0f); // create sound std::string soundProvider = options().get("Sound", "Provider", std::string("FMODProvider")); dlog << "AppBase: Initialising sound provider '" << soundProvider << "'" << dlog.endl; m_sound = (ISoundProvider*)Base::newObject(soundProvider); if (!m_sound) throwf("Couldn't initialize sound provider '" + soundProvider + "'"); // music manager loadConfig("music.ini"); loadConfig("musicmanager.ini"); m_music = new MusicManager; // Add sounds path filesystem().addFileMethod(new FileMethodDiskRelative(pathResources() + m_options->get("Sound", "SoundsPath", std::string("media\\sounds")))); // make main loop update thread #if USE_FIBERS m_mainLoopStep = new ThreadStepper(ThreadStepper::Delegate(this, (ThreadStepper::Delegate::FuncType)&SAppBase::doMainLoopUpdate)); add(*m_mainLoopStep); #endif }