Noxid
Reaction score
0

Profile posts Postings Media Albums About

  • I also noticed both KS and WTF story have a multiple save file option. I'm assuming this would require a lot of ASM crap as well? It might be interesting to try and do with one of my mods to further my ASM knowledge.
    Yeah, that's what I was learning towards. I guess it depends on how long it's going to take for the next one to come out.
    Thanks :3
    So Noxid, I have a question.
    I'm thinking of getting a 3DS. I have the money, but I've heard awful things about it, so I'm thinking about holding out until the second generation.
    Is it as bad as they say, or is it worth getting sooner?
    Okay, uh... I have a working model of undo/redo in a text editor and the source code.

    I'll give you the details behind the code as long as you import the right classes and such.

    Code:
        private UndoManagerTeam undoManageTeam = new UndoManagerTeam();
        private UndoAction undoActionObj = new UndoAction();
        private RedoAction redoActionObj = new RedoAction();
        private JMenuItem undoItem;
        private JMenuItem redoItem;

    Those were some of the fields, i.e. class variables, of my text editor GUI. There is a menu item for undo, a menu item for redo (which are attached to Ctrl+Z and Ctrl+Y respectively), an undo object, a redo object, and a team of undoManager objects.

    The only reason I have a "team" of undo managers instead of just one is that each text edit tab requires its own undo/redo capabilities. I assume you want the same feature for your TSC editor or whatever you're building.

    Code:
    private class UndoManagerTeam {
        private ArrayList<UndoManager> undoManageTeam =
                                       new ArrayList<UndoManager>();
        
        private void addManager() {
            undoManageTeam.add(new UndoManager());
        }
        
        private void removeManager(int index) {
            undoManageTeam.remove(index);
        }
        
        private UndoManager getCurrentManager() {
            int currentIndex = tabManageObj.getCurrentTabIndex();
            return undoManageTeam.get(currentIndex);
        }
    }

    The above code is the code for the undo manager team. It's just an abstraction for an ArrayList. UndoManager is a built-in java class.

    Code:
    private class CustomUndoableEditListener implements UndoableEditListener {
        @Override
        public void undoableEditHappened(UndoableEditEvent event) {
            undoManageTeam.getCurrentManager().addEdit(event.getEdit());
        }
    }
    
    private class UndoAction extends AbstractAction {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                UndoManager currentManager = undoManageTeam.getCurrentManager();
                if (currentManager.canUndo())
                    currentManager.undo();
            } catch (CannotUndoException exceptionInfo) {
                //Ignore the exception.
            }
        }
    }
    
    private class RedoAction extends AbstractAction {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                UndoManager currentManager = undoManageTeam.getCurrentManager();
                if (currentManager.canRedo())
                    currentManager.redo();
            } catch (CannotRedoException exceptionInfo) {
                //Ignore the exception.
            }
        }
    }

    The above code for RedoAction, UndoAction, and CustomUndoableEditListener are the basis for your undo/redo stuff.

    Code:
        private ArrayList<CustomUndoableEditListener> editListeners =
                new ArrayList<CustomUndoableEditListener>();
    
        private void addTab() {
            JScrollPane newScrollPane = new JScrollPane();
            JTextPane newTextPane = new JTextPane();
            newScrollPane.setViewportView(newTextPane);
            textPaneList.add(newTextPane);
            tabList.add(newScrollPane);
            mainTabbedPane.addTab("New File",newScrollPane);
            filesBeingEdited.add("");
            undoManageTeam.addManager();
            editListeners.add(new [COLOR="Red"][B]CustomUndoableEditListener[/B][/COLOR]());
            addPropertiesToTextPane(newTextPane);
            switchToLastTab();
        }

    Finally, whenever a new tab is created by the user, an new CustomUndoableEditListener must be created for that tab.

    I'm sorry if that made little sense. I copy-pasta'd most of the undo/redo code from the Java tutorials and made modifications so that it'd work for multiple tabs. I got my information here: http://download.oracle.com/javase/tutorial/uiswing/components/generaltext.html#undoableedits

    So yeah. Feel free to bombard me with additional questions. The undo/redo stuff is not just limited to text, so you could use it to undo CS map editing actions and emulate the other stuff you see in CaveEditor.
    I fond that wierd now that i think of it, that I would start a thread like that.
    I am praying that doublethink dosen't find out,
    He absolutly HATED cave story site
    EDIT: i hated it too
    Cave story site is dead forever... plus only stalkers would now that, plus i do not have multiple accounts because cavestorysite is not an account it is like a mental scar that haunts me on the forums, as for that smittybot5 guy was created for a friend of mine who is to lazy to create an account on his own...
    Why must the moderators care so much about a person who likes the forums alot...
    and take 8 one of the main reasons for this account... welll i gess i am bieng banned now goodbye:sue::momo:
    What happened to the "add new" button of Cave Editor? I earlier made all my mods using the "add new" button [with a certain version of CE (forgot which)] and never ever had a problem. Now I have downloaded CE again and it does very weird things when I use that button. Any idea what happened to it? It was good eariler and it is not now - it's like someone broke it and uploaded the broken version.
  • Loading…
  • Loading…
  • Loading…
  • Loading…
Back
Top