コード例 #1
0
    private void OnButtonPress(object o, ButtonPressEventArgs args)
    {
        if (args.Event.Button == 1)
        {
            application.SetToolObjects();

            Vector MousePos = new Vector((float)args.Event.X,
                                         (float)args.Event.Y);
            int?objectNr = GetObjectNrByPosition(MousePos);
            int selected;
            if (!objectNr.HasValue)
            {
                return;
            }
            else
            {
                selected = (int)objectNr;
            }
            if (selected < gameObjectTypes.Count)
            {
                if (SelectedObjectNr != selected)
                {
                    SelectedObjectNr = selected;
                    if (application.CurrentSector != null)
                    {
                        Type   type = gameObjectTypes[selected];
                        Sprite Icon = gameObjectSprites[selected];
                        if (type != null)
                        {
                            ITool editor = new ObjectCreationTool(application, application.CurrentSector, type, Icon);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name + "\"");
                        }
                        else
                        {
                            ITool editor = new ObjectSelectTool(application, application.CurrentSector);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: none selected ");
                        }
                    }
                    QueueDraw();
                }
            }
        }
    }
コード例 #2
0
    private void OnButtonPress(object o, ButtonPressEventArgs args)
    {
        if(args.Event.Button == 1) {
            application.SetToolObjects();

            Vector MousePos = new Vector((float) args.Event.X,
                                         (float) args.Event.Y);
            int? objectNr = GetObjectNrByPosition(MousePos);
            int selected;
            if (!objectNr.HasValue) {
                return ;
            } else {
                selected = (int)objectNr;
            }
            if( selected  < gameObjectTypes.Count ){
                if( SelectedObjectNr != selected ){
                    SelectedObjectNr = selected;
                    if( application.CurrentSector != null ) {
                        Type type = gameObjectTypes[selected];
                        Sprite Icon = gameObjectSprites[selected];
                        if(type != null) {
                            ITool editor = new ObjectCreationTool(application, application.CurrentSector, type, Icon);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name +"\"");
                        } else {
                            ITool editor = new ObjectSelectTool(application, application.CurrentSector);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: none selected ");
                        }
                    }
                    QueueDraw();
                }
            }
        }
    }