Browse Source

编辑状态

baowen 6 hours ago
parent
commit
a949dfdd02

File diff suppressed because it is too large
+ 208 - 154
assets/editor/prefab/SuperFindPanel.prefab


+ 1 - 1
assets/editor/prefab/spine/spine01.prefab

@@ -1,7 +1,7 @@
 [
   {
     "__type__": "cc.Prefab",
-    "_name": "",
+    "_name": "spine01",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_native": "",

+ 6 - 0
assets/editor/script/FindItem.ts

@@ -104,6 +104,7 @@ export default class FindItem extends Component {
         switch (this.currentState) {
             case ItemState.EDIT:
                 this.scaleSlider.node.active = true;
+                this.redFrame.active = true
                 break;
 
             case ItemState.NORMAL:
@@ -214,4 +215,9 @@ export default class FindItem extends Component {
         const spineNode = instantiate(prefab);
         this.spineNode.addChild(spineNode);
     }   
+
+    showOrHideScale(isShow: boolean)
+    {
+        this.scaleSlider.node.active = isShow;
+    }
 }

+ 8 - 0
assets/editor/script/LevelContainer.ts

@@ -321,4 +321,12 @@ export class LevelContainer extends Component {
         this.swtichEditMode(false);
         this.genLvlContent(this._bgPath, Skin.getSelectSkinPath(), Difficulty.difficutyData.difficutyCount, this._itemScales);
     }
+
+    showOrHideScale(isShow: boolean)
+    {
+        for(let i = 0; i < this._findItems.length; i++)
+        {
+            this._findItems[i].showOrHideScale(isShow)
+        }
+    }
 }

+ 32 - 2
assets/editor/script/SelectMapPanel.ts

@@ -1,4 +1,4 @@
-import { _decorator, Button, Component, instantiate, Node, ScrollView } from 'cc';
+import { _decorator, Button, Component, EditBox, instantiate, Node, ScrollView, UITransform, Vec2, Vec3 } from 'cc';
 import { LayerMgr } from '../../script/Manager/LayerMgr';
 import { allMapList, getAllMapKeys, MapData, UserMap } from '../../script/Manager/LocalDataMgr';
 import { MapItem } from './MapItem';
@@ -14,6 +14,10 @@ export class SelectMapPanel extends Component {
     btnClose: Button = null;
     @property(ScrollView)
     scrollView:ScrollView = null;
+    @property(EditBox)
+    editBox:EditBox = null;
+    @property(Button)
+    btnTurn:Button = null;
 
     _mapData:MapData = null
     _allMapList:{ [key: number]: string };
@@ -21,6 +25,7 @@ export class SelectMapPanel extends Component {
     _hasCreatedItems:boolean = false;
     protected start(): void {
         this.btnClose.node.on(Node.EventType.TOUCH_END,this.onBtnCloseClick,this)
+        this.btnTurn.node.on(Node.EventType.TOUCH_END,this.scrollToItem,this)
     }
 
     init() {
@@ -96,7 +101,32 @@ export class SelectMapPanel extends Component {
     {
 
     }
-    
+
+    scrollToItem() {
+        let page = parseInt(this.editBox.string);
+        if (isNaN(page)) return;
+        let itemNode = this.itemRoot.children[page];
+        if (!itemNode) return;
+
+        const viewHeight = this.scrollView.node.getComponent(UITransform).height;
+        const itemHeight = itemNode.getComponent(UITransform).height;
+
+        // 获取itemNode在content中的位置(局部坐标)
+        const itemPos = itemNode.position;
+        const itemTop = -itemPos.y;
+        // 使item在视图中居中需要滚动的偏移量(从content顶部到视图顶部的距离)
+        let offset = itemTop - (viewHeight - itemHeight) / 2;
+
+        // 获取内容总高度(content节点的高度)
+        const contentHeight = this.itemRoot.getComponent(UITransform).height;
+        // 最大可滚动的偏移量
+        const maxScrollOffset = Math.max(0, contentHeight - viewHeight);
+        // 限制offset在[0, maxScrollOffset]之间
+        offset = Math.max(0, Math.min(maxScrollOffset, offset));
+
+        // 滚动到该偏移量
+        this.scrollView.scrollToOffset(new Vec2(0, offset), 0.5);
+    }
 }
 
 

+ 3 - 1
assets/editor/script/SkinItem.ts

@@ -1,4 +1,4 @@
-import { _decorator, Button, Component, instantiate, Node, Prefab, sp, Sprite, Vec2 } from 'cc';
+import { _decorator, Button, Component, instantiate, Node, Prefab, sp, Sprite, Vec2, Vec3 } from 'cc';
 import {Skin } from '../../script/Manager/LocalDataMgr';
 import { LayerMgr } from '../../script/Manager/LayerMgr';
 const { ccclass, property } = _decorator;
@@ -28,11 +28,13 @@ export class SkinItem extends Component {
     {
         let skin = instantiate(spine)
         this.skinRoot.addChild(skin)
+        skin.setPosition(Vec3.ZERO)
         skin.position = skin.position.clone().add3f(spineOffset.x,spineOffset.y,0)
         this.selectedSprite.node.active = isSelect
         this._isSelected = isSelect
         this._key = key
         this._spine = skin.getComponent(sp.Skeleton)
+        if(!this._spine.getCurrent(0))
         this._spine.setAnimation(0,animName,true)
     }
 

+ 32 - 7
assets/editor/script/SuperFindPanel.ts

@@ -2,9 +2,8 @@ import { _decorator, Component, Label, Node, Prefab } from 'cc';
 import { SelectDifficultyPanel } from './SelectDifficultyPanel';
 import { SelectSkinPanel } from './SelectSkinPanel';
 import { SelectMapPanel } from './SelectMapPanel';
-import { LayerMgr } from '../../script/Manager/LayerMgr';
 import { LevelContainer } from './LevelContainer';
-import { allSkinList, defaultSkin, Difficulty, Skin, SuperFind, UserSuperFindData } from '../../script/Manager/LocalDataMgr';
+import { defaultSkin, Difficulty, Skin, SuperFind} from '../../script/Manager/LocalDataMgr';
 import EventMgr from '../../script/Manager/EventMgr';
 const { ccclass, property } = _decorator;
 
@@ -18,15 +17,22 @@ export class SuperFindPanel extends Component {
     selMapPanel: SelectMapPanel = null
     @property(LevelContainer)
     lvlContainer: LevelContainer = null
+
+    @property(Node)
+    editBtns:Node = null
+    @property(Node)
+    noEditBtns:Node = null
     @property(Label)
     tipLabel: Label = null
     @property(Label)
     tipLabel2: Label = null
+    @property(Label)
+    showOrHideScaleLabel: Label = null
 
     @property(Node)
     bottom: Node = null
 
-    _editMode:boolean = false
+    _showScale:boolean = false
 
     protected start(): void {
         this.init()
@@ -53,6 +59,18 @@ export class SuperFindPanel extends Component {
         this.selMapPanel.node.active = true;
         this.selMapPanel.init();
     }
+    OpenEditBtns()
+    {
+        this.editBtns.active = true
+        this.lvlContainer.swtichEditMode(true)
+        this.noEditBtns.active = false
+    }
+    CloseEditBtns()
+    {
+        this.editBtns.active = false
+        this.lvlContainer.swtichEditMode(false)
+        this.noEditBtns.active = true
+    }
     CloseSelDifPanel() {
         this.selDifPanel.node.active = false;
     }
@@ -62,16 +80,16 @@ export class SuperFindPanel extends Component {
     CloseSelMapPanel() {
         this.selMapPanel.node.active = false;
     }
-
+    
     close()
     {
         this.node.destroy()
     }
 
-    onEditClick()
+    onEditFinishClick()
     {
-        this._editMode = !this._editMode
-        this.lvlContainer.swtichEditMode(this._editMode)
+
+        this.CloseEditBtns()
     }
 
     onRegenerateClick()
@@ -94,6 +112,13 @@ export class SuperFindPanel extends Component {
         this.tipLabel.string = SuperFind.superFindData.title
         this.tipLabel2.string = SuperFind.superFindData.levelDesc
     }
+
+    showOrHideScale()
+    {
+        this._showScale = !this._showScale
+        this.lvlContainer.showOrHideScale(this._showScale)
+        this.showOrHideScaleLabel.string = this._showScale?"隐藏缩放":"显示缩放"
+    }
 }
 
 

Some files were not shown because too many files changed in this diff