| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- new GuiControl(UVEditorOverlay, EditorGuiGroup) {
- canSaveDynamicFields = "0";
- Profile = "ToolsGuiOverlayProfile";
- Enabled = "1";
- isContainer = "1";
- HorizSizing = "right";
- VertSizing = "bottom";
- Position = "0 0";
- Extent = "1024 768";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- hovertime = "1000";
- new GuiWindowCtrl(UVEditor){
- profile = "ToolsGuiWindowProfile";
- HorizSizing = "center";
- VertSizing = "center";
- resizeWidth = "0";
- resizeHeight = "0";
- canClose = "1";
- canMinimize = "0";
- canMaximize = "0";
- position = "72 98";
- extent =" 453 340";
- MinExtent = "453 340";
- text = "UV Editor";
- closeCommand = "UVEditor.hideDialog();";
- EdgeSnap = "0";
- canCollapse = "0";
- visible = "0";
-
- new GuiTextCtrl() {
- text = "0.0";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "26 24";
- Extent = "32 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "U";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextCenterProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "138 24";
- Extent = "32 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "1.0";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextRightProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "250 24";
- Extent = "32 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "0.0";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextRightProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "4 36";
- Extent = "18 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "V";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextRightProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "4 159";
- Extent = "18 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "1.0";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextRightProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "4 282";
- Extent = "18 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
-
- new GuiControl(){
- HorizSizing = "right";
- VertSizing = "bottom";
- profile = "ToolsGuiSolidDefaultProfile";
- position = "25 37";
- extent = "258 258";
- };
-
- new GuiBitmapCtrl(){
- internalName = "bitmapPreview";
- HorizSizing = "right";
- VertSizing = "bottom";
- profile = "ToolsGuiDefaultProfile";
- position = "26 38";
- extent = "256 256";
- wrap = "0";
- bitmap = "";
- };
- new GuiRectHandles(){
- internalName = "uvHandles";
- class = "UVEditorRectHandles";
- Profile = "ToolsGuiDefaultProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "26 38";
- extent = "256 256";
- };
- new GuiBitmapBorderCtrl() {
- profile = "ToolsGuiGroupBorderProfile";
- horizSizing = "width";
- vertSizing = "bottom";
- position = "26 300";
- extent = "256 30";
- minExtent = "0 0";
- visible = "1";
- setFirstResponder = "0";
- modal = "1";
- helpTag = "0";
-
- new GuiTextCtrl() {
- text = "Handle Color:";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "10 7";
- Extent = "70 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiPopupMenuCtrlEx(){
- internalName = "colorPopup";
- Profile = "ToolsGuiPopUpMenuProfile";
- Position = "80 5";
- Extent = "126 20";
- HorizSizing = "right";
- VertSizing = "bottom";
- Command = "UVEditor.onColorSelect();";
- reverseTextList = "0";
- };
- };
-
- new GuiBitmapBorderCtrl() {
- profile = "ToolsGuiGroupBorderProfile";
- horizSizing = "width";
- vertSizing = "bottom";
- position = "292 38";
- extent = "151 256";
- minExtent = "0 0";
- visible = "1";
- setFirstResponder = "0";
- modal = "1";
- helpTag = "0";
-
- new GuiTextCtrl() {
- text = "U:";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "10 12";
- Extent = "32 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl() {
- internalName = "UVX";
- class = "UVEditorUVTextEdit";
- historySize = "0";
- password = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- passwordMask = "*";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiNumericTextEditProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "44 10";
- Extent = "64 18";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "1";
- };
- new GuiTextCtrl() {
- text = "V:";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "10 32";
- Extent = "32 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl() {
- internalName = "UVY";
- class = "UVEditorUVTextEdit";
- historySize = "0";
- password = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- passwordMask = "*";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiNumericTextEditProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "44 30";
- Extent = "64 18";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "1";
- };
- new GuiTextCtrl() {
- text = "Width:";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "10 52";
- Extent = "32 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl() {
- internalName = "UVW";
- class = "UVEditorUVTextEdit";
- historySize = "0";
- password = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- passwordMask = "*";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiNumericTextEditProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "44 50";
- Extent = "64 18";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "1";
- };
- new GuiTextCtrl() {
- text = "Height:";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiTextProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "10 72";
- Extent = "32 14";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl() {
- internalName = "UVH";
- class = "UVEditorUVTextEdit";
- historySize = "0";
- password = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- passwordMask = "*";
- maxLength = "1024";
- Margin = "0 0 0 0";
- Padding = "0 0 0 0";
- AnchorTop = "1";
- AnchorBottom = "0";
- AnchorLeft = "1";
- AnchorRight = "0";
- isContainer = "0";
- Profile = "ToolsGuiNumericTextEditProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "44 70";
- Extent = "64 18";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- canSaveDynamicFields = "1";
- };
- new GuiButtonCtrl(){
- HorizSizing = "right";
- VertSizing = "top";
- profile = "ToolsGuiButtonProfile";
- position = "44 94";
- extent = "64 20";
- text = "Reset";
- command = "UVEditor.reset();";
- tooltip = "Reset the UV fields to their original values.";
- };
- };
- new GuiButtonCtrl(){
- internalName = "OKButton";
- HorizSizing = "left";
- VertSizing = "top";
- profile = "ToolsGuiButtonProfile";
- position = "292 306";
- extent = "94 24";
- text = "OK";
- command = "UVEditor.apply();";
- Accelerator = "return";
- };
- new GuiButtonCtrl(){
- HorizSizing = "left";
- VertSizing = "top";
- profile = "ToolsGuiButtonProfile";
- position = "391 306";
- extent = "52 24";
- text = "Cancel";
- command = "UVEditor.hideDialog();";
- Accelerator = "escape";
- };
- };
- };
- //-----------------------------------------------------------------------------
- function UVEditor::showDialog( %this, %applyCallback, %obj, %uv)
- {
- // Set the select callback
- UVEditor.applyCallback = %applyCallback;
-
- // Set the initial UV coordinates
- UVEditor.originalUV = %uv;
- UVEditor-->uvHandles.handleRect = %uv;
- UVEditor.setTextValues(%uv);
-
- // Get the preview bitmap. Code copied from Material Selector.
- %material = %obj.material;
- if( %material.toneMap[0] $= "" && %material.diffuseMap[0] $= "" && !isObject(%material.cubemap) )
- {
- %previewImage = "core/art/warnmat";
- }
- else
- {
- if( %material.toneMap[0] !$= "" )
- %previewImage = %material.toneMap[0];
- else if( %material.diffuseMap[0] !$= "" )
- %previewImage = %material.diffuseMap[0];
- else if( %material.cubemap.cubeFace[0] !$= "" )
- %previewImage = %material.cubemap.cubeFace[0];
-
- %materialDiffuse = %previewImage;
- %materialPath = %material.getFilename();
- if( strchr( %materialDiffuse, "/") $= "" )
- {
- %k = 0;
- while( strpos( %materialPath, "/", %k ) != -1 )
- {
- %foo = strpos( %materialPath, "/", %k );
- %k = %foo + 1;
- }
-
- %foobar = getSubStr( %materialPath , %k , 99 );
- %previewImage = strreplace( %materialPath, %foobar, %previewImage );
- }
- else
- %previewImage = strreplace( %materialPath, %materialPath, %previewImage );
- }
-
- UVEditor-->bitmapPreview.setBitmap(%previewImage);
-
- // Set up the color popup
- %popup = UVEditor-->colorPopup;
- %popup.clear();
- %popup.add("Default1|255|134|0");
- %popup.add("Default2|0|121|255");
- %popup.add("Black|0|0|0");
- %popup.add("Gray|100|100|100");
- %popup.add("White|255|255|255");
- %popup.add("Red|255|0|0");
- %popup.add("Green|0|255|0");
- %popup.add("Blue|0|0|255");
- %popup.add("Yellow|255|255|0");
- %popup.add("Magenta|255|0|255");
- %popup.add("Cyan|0|255|255");
- %popup.setSelected(EditorSettings.value("WorldEditor/Color/uvEditorHandleColor"));
- UVEditor-->uvHandles.useCustomColor = true;
- UVEditor-->uvHandles.handleColor = %popup.getColorById(%popup.getSelected());
-
- Canvas.pushDialog(UVEditorOverlay);
- UVEditor.setVisible(1);
- }
- function UVEditor::hideDialog( %this )
- {
- UVEditor.setVisible(0);
- Canvas.popDialog(UVEditorOverlay);
- }
- function UVEditor::apply( %this )
- {
- eval( "" @ UVEditor.applyCallback @ "(\"" @ UVEditor-->uvHandles.handleRect @ "\");");
- UVEditor.hideDialog();
- }
- function UVEditor::reset( %this )
- {
- UVEditor-->uvHandles.handleRect = UVEditor.originalUV;
- UVEditor.setTextValues(UVEditor.originalUV);
- }
- function UVEditor::setTextValues( %this, %uv )
- {
- UVEditor-->UVX.setText( getWord(%uv, 0) );
- UVEditor-->UVY.setText( getWord(%uv, 1) );
- UVEditor-->UVW.setText( getWord(%uv, 2) );
- UVEditor-->UVH.setText( getWord(%uv, 3) );
- }
- function UVEditor::onColorSelect( %this )
- {
- UVEditor-->uvHandles.useCustomColor = true;
- %sel = $ThisControl.getSelected();
- UVEditor-->uvHandles.handleColor = $ThisControl.getColorById(%sel);
- EditorSettings.setValue( "WorldEditor/Color/uvEditorHandleColor", %sel );
- }
- //-----------------------------------------------------------------------------
- function UVEditorRectHandles::onHandleRectChange( %this )
- {
- %uv = UVEditor-->uvHandles.handleRect;
- UVEditor.setTextValues(%uv);
- }
- //-----------------------------------------------------------------------------
- function UVEditorUVTextEdit::onValidate( %this )
- {
- %u = UVEditor-->UVX.getValue();
- %v = UVEditor-->UVY.getValue();
- %w = UVEditor-->UVW.getValue();
- %h = UVEditor-->UVH.getValue();
-
- // Check limits
-
- if(%u < 0)
- %u = 0;
- if(%u > 1)
- %u = 1;
- if(%v < 0)
- %v = 0;
- if(%v > 1)
- %v = 1;
-
- if(%w < 0)
- %w = 0;
- if(%w > 1)
- %w = 1;
- if(%h < 0)
- %h = 0;
- if(%h > 1)
- %h = 1;
-
- if((%u+%w) > 1)
- %w = 1 - %u;
- if((%v+%h) > 1)
- %h = 1 - %v;
-
- // Apply values
- UVEditor-->UVX.setText( %u );
- UVEditor-->UVY.setText( %v );
- UVEditor-->UVW.setText( %w );
- UVEditor-->UVH.setText( %h );
-
- UVEditor-->uvHandles.handleRect = %u SPC %v SPC %w SPC %h;
- }
- function UVEditorUVTextEdit::onGainFirstResponder( %this )
- {
- %this.selectAllText();
- }
|