Torque3D Documentation / _generateds / VEditorWindow.cpp

VEditorWindow.cpp

Engine/source/Verve/GUI/VEditorWindow.cpp

More...

Public Functions

DefineEngineMethod(VEditorWindow , resetCursor , void , () , "( )" )
DefineEngineMethod(VEditorWindow , setVideoMode , void , (S32 width, S32 height, bool fullscreen, S32 bitDepth, S32 refreshRate, S32 antiAliasLevel) , (800, 600, false, 32, 60, 0) )

Detailed Description

Public Functions

DefineEngineMethod(VEditorWindow , resetCursor , void , () , "( )" )

DefineEngineMethod(VEditorWindow , setVideoMode , void , (S32 width, S32 height, bool fullscreen, S32 bitDepth, S32 refreshRate, S32 antiAliasLevel) , (800, 600, false, 32, 60, 0) )

IMPLEMENT_CONOBJECT(VEditorWindow )

  1
  2//-----------------------------------------------------------------------------
  3// Verve
  4// Copyright (C) 2014 - Violent Tulip
  5//
  6// Permission is hereby granted, free of charge, to any person obtaining a copy
  7// of this software and associated documentation files (the "Software"), to
  8// deal in the Software without restriction, including without limitation the
  9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10// sell copies of the Software, and to permit persons to whom the Software is
 11// furnished to do so, subject to the following conditions:
 12//
 13// The above copyright notice and this permission notice shall be included in
 14// all copies or substantial portions of the Software.
 15//
 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 22// IN THE SOFTWARE.
 23//-----------------------------------------------------------------------------
 24#include "Verve/GUI/VEditorWindow.h"
 25#include "gfx/gfxInit.h"
 26
 27//-----------------------------------------------------------------------------
 28IMPLEMENT_CONOBJECT( VEditorWindow );
 29//-----------------------------------------------------------------------------
 30
 31bool VEditorWindow::onAdd( void )
 32{
 33    if ( !Parent::onAdd() )
 34    {
 35        return false;
 36    }
 37
 38    GFXAdapter *adapter = GFXInit::getBestAdapterChoice();
 39    if ( adapter && adapter->mType != NullDevice )
 40    {
 41        mPlatformWindow->setMinimumWindowSize( Point2I( 904, 287 ) );
 42    }
 43
 44    return true;
 45}
 46
 47//-----------------------------------------------------------------------------
 48
 49DefineEngineMethod( VEditorWindow, resetCursor, void, (),, "( )" )
 50{
 51    S32 currCursor = PlatformCursorController::curArrow;
 52    if ( object->mCursorChanged == currCursor )
 53    {
 54        return;
 55    }
 56
 57    PlatformWindow *window = object->getPlatformWindow();
 58    PlatformCursorController *controller = window->getCursorController();
 59
 60    if( object->mCursorChanged != -1)
 61    {
 62        controller->popCursor();
 63    }
 64
 65    controller->pushCursor(currCursor);
 66    object->mCursorChanged = currCursor;   
 67
 68    Platform::setWindowLocked( false );
 69}
 70
 71DefineEngineMethod( VEditorWindow, setVideoMode, void, (S32 width, S32 height, bool fullscreen, S32 bitDepth, S32 refreshRate, S32 antiAliasLevel),
 72               (800,600,false,32,60, 0),
 73               "(int width, int height, bool fullscreen, [int bitDepth], [int refreshRate])\n"
 74               "Change the video mode of this canvas. This method has the side effect of setting the $pref::Video::mode to the new values.\n\n"
 75               "\\param width The screen width to set.\n"
 76               "\\param height The screen height to set.\n"
 77               "\\param fullscreen Specify true to run fullscreen or false to run in a window\n"
 78               "\\param bitDepth [optional] The desired bit-depth. Defaults to the current setting. This parameter is ignored if you are running in a window.\n"
 79               "\\param refreshRate [optional] The desired refresh rate. Defaults to the current setting. This parameter is ignored if you are running in a window"
 80                    "\\param antialiasLevel [optional] The level of anti-aliasing to apply 0 = none" )
 81{
 82   if (!object->getPlatformWindow())
 83      return;
 84
 85   // Update the video mode and tell the window to reset.
 86   GFXVideoMode vm = object->getPlatformWindow()->getVideoMode();
 87
 88   bool changed = false;
 89   if (width == 0 && height > 0)
 90   {
 91      // Our width is 0 but our height isn't...
 92      // Try to find a matching width
 93      for(S32 i=0; i<object->getPlatformWindow()->getGFXDevice()->getVideoModeList()->size(); i++)
 94      {
 95         const GFXVideoMode &newVm = (*(object->getPlatformWindow()->getGFXDevice()->getVideoModeList()))[i];
 96
 97         if(newVm.resolution.y == height)
 98         {
 99            width = newVm.resolution.x;
100            changed = true;
101            break;
102         }
103      }
104   }
105   else if (height == 0 && width > 0)
106   {
107      // Our height is 0 but our width isn't...
108      // Try to find a matching height
109      for(S32 i=0; i<object->getPlatformWindow()->getGFXDevice()->getVideoModeList()->size(); i++)
110      {
111         const GFXVideoMode &newVm = (*(object->getPlatformWindow()->getGFXDevice()->getVideoModeList()))[i];
112
113         if(newVm.resolution.x == width)
114         {
115            height = newVm.resolution.y;
116            changed = true;
117            break;
118         }
119      }
120   }
121
122   if (width == 0 || height == 0)
123   {
124      // Got a bad size for both of our dimensions or one of our dimensions and
125      // didn't get a match for the other default back to our current resolution
126      width  = vm.resolution.x;
127      height = vm.resolution.y;
128
129      changed = true;
130   }
131
132   if (changed)
133      Con::errorf("GuiCanvas::setVideoMode(): Error - Invalid resolution of (%d, %d) - attempting (%d, %d)", width, height, width, height);
134
135   vm.resolution  = Point2I(width, height);
136   vm.fullScreen  = fullscreen;
137
138   vm.bitDepth = bitDepth;
139   vm.refreshRate = refreshRate;
140
141   vm.antialiasLevel = antiAliasLevel;
142
143#ifndef TORQUE_OS_XENON
144   object->getPlatformWindow()->setVideoMode(vm);
145#endif
146}
147