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 row = FirstRow + (int)Math.Floor(MousePos.Y / ROW_HEIGHT); int column = (int)Math.Floor(MousePos.X / COLUMN_WIDTH); if (column >= TILES_PER_ROW) { return; } int selected = TILES_PER_ROW * row + column; if (selected < gameObjectTypes.Count) { if (SelectedObjectNr != selected) { SelectedObjectNr = selected; if (application.CurrentSector != null) { Type type = gameObjectTypes[selected]; Sprite Icon = gameObjectSprites[selected]; if (type != null) { IEditor editor = new ObjectCreationEditor(application, application.CurrentSector, type, Icon); application.SetEditor(editor); application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name + "\""); } else { IEditor editor = new ObjectsEditor(application, application.CurrentSector); application.SetEditor(editor); application.PrintStatus("ObjectListWidget: none selected "); } } QueueDraw(); } } } }
private void OnButtonPress(object o, ButtonPressEventArgs args) { if(args.Event.Button == 1) { Vector MousePos = new Vector((float) args.Event.X, (float) args.Event.Y); int row = FirstRow + (int) Math.Floor( MousePos.Y / ROW_HEIGHT ); int column = (int) Math.Floor (MousePos.X / COLUMN_WIDTH); if( column >= TILES_PER_ROW ){ return; } int selected = TILES_PER_ROW * row + column; if( selected < gameObjectTypes.Count ){ if( SelectedObjectNr != selected ){ SelectedObjectNr = selected; if( application.CurrentSector != null ) { Type type = gameObjectTypes[selected]; if(type != null) { IEditor editor = new ObjectCreationEditor(application, application.CurrentSector, type); application.SetEditor(editor); application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name +"\""); } else { IEditor editor = new ObjectsEditor(application, application.CurrentSector); application.SetEditor(editor); application.PrintStatus("ObjectListWidget: none selected "); } } QueueDraw(); } } } }