This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 10147 for ps


Ignore:
Timestamp:
08/31/11 04:58:57 (13 years ago)
Author:
brian
Message:

Convert delete dialog to new style. Fixes #937

Location:
ps/trunk/binaries/data/mods/public/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/gui/msgbox/msgbox.xml

    r10122 r10147  
    88        var mbTitleObj = getGUIObjectByName("mbTitleBar");
    99        var mbTextObj = getGUIObjectByName("mbText");
    10        
     10
    1111        var mbButton1Obj = getGUIObjectByName("mbButton1");
    1212        var mbButton2Obj = getGUIObjectByName("mbButton2");
     
    1616        var mbLRDiff = data.width / 2;     // Message box left/right difference from 50% of screen
    1717        var mbUDDiff = data.height / 2;    // Message box up/down difference from 50% of screen
    18        
     18
    1919        var mbSizeString = "50%-" + mbLRDiff + " 50%-" + mbUDDiff + " 50%+" + mbLRDiff + " 50%+" + mbUDDiff;
    20        
     20
    2121        mbMainObj.size = mbSizeString;
    22        
     22
    2323        // Texts
    2424        mbTitleObj.caption  = data.title;
     
    101101                type="text"
    102102                style="CenteredLabelText"
    103                 size="30 30 100%-30 100%-100"
     103                size="5% 20% 95% 100%-96"
    104104            />
    105                        
     105
    106106            <object name="mbButton1"
    107107                style="StoneButton"
    108108                type="button"
    109109                hidden="true"
    110                 size="40 100%-50 33%-30 100%-20" 
     110                size="40 100%-50 33%-30 100%-20"
    111111            />
    112112            <object name="mbButton2"
     
    114114                type="button"
    115115                hidden="true"
    116                 size="33%+30 100%-50 66%-40 100%-20" 
     116                size="33%+30 100%-50 66%-40 100%-20"
    117117            />
    118118            <object name="mbButton3"
  • ps/trunk/binaries/data/mods/public/gui/session/input.js

    r10007 r10147  
    8888        });
    8989    }
    90    
     90
    9191    return false;
    9292}
     
    114114{
    115115    var selection = g_Selection.toList();
    116    
     116
    117117    // If the selection doesn't exist, no action
    118118    var entState = GetEntityState(selection[0]);
     
    126126        return entState && entState.player == playerID;
    127127    });
    128    
     128
    129129    if (!g_DevSettings.controlAll && !allOwnedByPlayer)
    130130        return {"possible": false};
     
    136136    });
    137137
    138    
     138
    139139    if (!target)
    140140    {
     
    149149    if (haveRallyPoints && selection.indexOf(target) != -1 && action == "unset-rallypoint")
    150150        return {"possible": true};
    151        
     151
    152152    // Look at the first targeted entity
    153153    // (TODO: maybe we eventually want to look at more, and be more context-sensitive?
     
    164164    // can return to the dropsite, can build the foundation, or can attack the enemy
    165165    var simState = Engine.GuiInterfaceCall("GetSimulationState");
    166    
     166
    167167    for each (var entityID in selection)
    168168    {
     
    170170        if (!entState)
    171171            continue;
    172        
     172
    173173        var playerState = simState.players[entState.player];
    174174        var playerOwned = (targetState.player == entState.player);
     
    176176        var enemyOwned = playerState.isEnemy[targetState.player];
    177177        var gaiaOwned = (targetState.player == 0);
    178        
     178
    179179        // Find the resource type we're carrying, if any
    180180        var carriedType = undefined;
     
    240240        return undefined;
    241241    }
    242    
     242
    243243    // If the selection doesn't exist, no action
    244244    var entState = GetEntityState(selection[0]);
     
    252252        return entState && entState.player == playerID;
    253253    });
    254    
     254
    255255    if (!g_DevSettings.controlAll && !allOwnedByPlayer)
    256256        return undefined;
     
    289289                return {"type": "repair", "cursor": "action-repair", "target": target};
    290290            else
    291                 return {"type": "none", "cursor": "action-repair-disabled", "target": undefined};   
     291                return {"type": "none", "cursor": "action-repair-disabled", "target": undefined};
    292292            break;
    293293        }
     
    308308            return {"type": "returnresource", "cursor": actionInfo.cursor, "target": target};
    309309        else if (getActionInfo("build", target).possible)
    310             return {"type": "build", "cursor": "action-build", "target": target};   
     310            return {"type": "build", "cursor": "action-build", "target": target};
    311311        else if (getActionInfo("repair", target).possible)
    312312            return {"type": "build", "cursor": "action-repair", "target": target};
     
    374374
    375375        entStateList.push(entState);
    376     }           
     376    }
    377377
    378378    // If there are no units, check if there are defensive entities in the selection
     
    407407    // be processed here before being passed on, and propagation will stop if this function
    408408    // returns true)
    409     // 
     409    //
    410410    // TODO: it'd probably be nice to have a better state-machine system, with guaranteed
    411411    // entry/exit functions, since this is a bit broken now
     
    452452                var preferredEntities = getPreferredEntities(ents)
    453453
    454                 if (preferredEntities.length)           
     454                if (preferredEntities.length)
    455455                    ents = preferredEntities;
    456456
     
    483483
    484484                g_Selection.setHighlightList([]);
    485                
     485
    486486                inputState = INPUT_NORMAL;
    487487                return true;
     
    490490        }
    491491        break;
    492    
     492
    493493    case INPUT_BUILDING_CLICK:
    494494        switch (ev.type)
     
    569569                placementPosition.z = snapData.z;
    570570            }
    571            
     571
    572572            updateBuildingPlacementPreview();
    573573            break;
     
    719719            var dragDeltaX = ev.x - dragStart[0];
    720720            var dragDeltaY = ev.y - dragStart[1];
    721            
     721
    722722            if (Math.abs(dragDeltaX) >= maxDragDelta || Math.abs(dragDeltaY) >= maxDragDelta)
    723723            {
     
    744744                var selectedEntity = ents[0];
    745745                var now = new Date();
    746                
     746
    747747                // If camera following and we select different unit, stop
    748748                if (Engine.GetFollowedEntity() != selectedEntity)
     
    757757                    var matchRank = true;
    758758                    var templateToMatch;
    759                    
     759
    760760                    // Check for double click or triple click
    761761                    if (!doubleClicked)
     
    782782                        }
    783783                    }
    784                    
     784
    785785                    // TODO: Should we handle "control all units" here as well?
    786786                    ents = Engine.PickSimilarFriendlyEntities(templateToMatch, showOffscreen, matchRank);
     
    811811                    g_Selection.addList(ents);
    812812                }
    813                
     813
    814814                inputState = INPUT_NORMAL;
    815815                return true;
     
    835835                placementPosition.z = snapData.z;
    836836            }
    837            
     837
    838838            updateBuildingPlacementPreview();
    839839
     
    922922        // TODO: Play a sound?
    923923        return true;
    924        
     924
    925925    case "set-rallypoint":
    926926        var target = Engine.GetTerrainAtPoint(ev.x, ev.y);
     
    942942        });
    943943        return true;
    944        
     944
    945945    case "none":
    946946        return true;
    947        
     947
    948948    default:
    949949        error("Invalid action.type "+action.type);
     
    10781078        var template = GetTemplateData(entState.template);
    10791079        var unitName = getEntityName(template);
    1080    
     1080
    10811081        var playerID = Engine.GetPlayerID();
    10821082        if (entState.player == playerID || g_DevSettings.controlAll)
     
    10891089                if (selection.length > 0)
    10901090                {
    1091                     var message = "Are you sure you want to\ndelete the selected units?";
    1092 
    1093                     var deleteFunction = function ()
    1094                     {
     1091                    closeMenu();
     1092                                        closeOpenDialogs();
     1093
     1094                                        var deleteFunction = function ()
     1095                    {
    10951096                        Engine.PostNetworkCommand({"type": "delete-entities", "entities": selection});
    10961097                    };
    10971098
    1098                     g_SessionDialog.open("Delete", message, null, 340, 160, deleteFunction);
     1099                                        var btCaptions = ["Yes", "No"];
     1100                                        var btCode = [deleteFunction, null];
     1101
     1102                                        messageBox(400, 200, "Destroy everything currently selected?", "Delete", 0, btCaptions, btCode);
    10991103                }
    11001104                break;
     
    12131217        var data = { prevUnit: lastIdleUnit, idleClass: classes[currIdleClass] };
    12141218        var newIdleUnit = Engine.GuiInterfaceCall("FindIdleUnit", data);
    1215    
     1219
    12161220        // Check if we have new valid entity
    12171221        if (newIdleUnit && newIdleUnit != lastIdleUnit)
     
    12211225            g_Selection.addList([lastIdleUnit]);
    12221226            Engine.CameraFollow(lastIdleUnit);
    1223            
     1227
    12241228            return;
    12251229        }
    1226        
     1230
    12271231        lastIdleUnit = 0;
    12281232        currIdleClass = (currIdleClass + 1) % classes.length;
    12291233    }
    1230    
     1234
    12311235    // TODO: display a message or play a sound to indicate no more idle units, or something
    12321236    // Reset for next cycle
  • ps/trunk/binaries/data/mods/public/gui/session/menu.js

    r10146 r10147  
    133133}
    134134
    135 function escapeKeyAction()
     135function closeOpenDialogs()
    136136{
    137137        closeMenu();
  • ps/trunk/binaries/data/mods/public/gui/session/session.xml

    r10146 r10147  
    4343
    4444        <object hotkey="leave">
    45             <action on="Press">escapeKeyAction();</action>
     45            <action on="Press">closeOpenDialogs();</action>
    4646        </object>
    4747
     
    422422                                                <action on="Press">
    423423                                                        closeMenu();
    424                                                         escapeKeyAction();
     424                                                        closeOpenDialogs();
    425425                                                        <![CDATA[
    426426                                                                var btCaptions = ["Yes", "No"];
Note: See TracChangeset for help on using the changeset viewer.