@EnigmaBot EnigmaBot released this Nov 24, 2018

Assets 6
Linux CMake for emake/Update Submodule (#52)

Update the enigma-dev submodule to the latest master and tweak the AppVeyor build to be compatible with FindProtobuf.

@EnigmaBot EnigmaBot released this Nov 17, 2018

Assets 6
Tree Drag & Drop (#51)

* Changed `TreeModel` constructor to accept `ResourceModelMap` so the tree model is capable of adding new resources to the map when doing a drag copy operation.
* Changed `MainWindow::CreateResource` to allocate a new `TreeNode` directly instead of through the root. I did this originally anticipating that `TreeModel::addNode` would be used by the drag and drop code, but ultimately it wasn't.
* Changed TreeModel::addNode to append the allocated child and undid the change in #47 we merged a few days ago.
* Created the helper `ResourceModelMap::CreateResourceName` which gives a unique name for a new resource of the given type. This was created by extracting the logic from `MainWindow::CreateResource` so that it could also be used by a drag copy operation. Again, I will reiterate from my previous comments on #42 that this can later be made more efficient by just caching the last number (maybe max id) used to create a new resource of that type.
* Changed the `dragDropMode` of the main window's tree view to `DragDrop` instead of `InternalMove` because we want to support copying the resources to the same target. Without this change the copy operation (done by holding CTRL during the drag) becomes just a move operation when the source and target are the same view.
* Changed `TreeModel::flags` to indicate `Qt::ItemIsDropEnabled` where appropriate (e.g, folders & the root) and `Qt::ItemIsDragEnabled` where appropriate (e.g, every valid/visible node).
* Changed `TreeModel::parent` to return an invalid model index, which means the root, when the parent node found in the `parents` map is null. This is actually an error condition and should hypothetically only occur if a logic mistake is made somewhere else, but I ran into it while doing this drag and drop and hence made the change.
* Added `TreeModel::supportedDropActions` to indicate that we support `MoveAction` and not just `CopyAction` (the default implementation of `QAbstractItemModel`).
* Added the private inline helper `TreeNode::treeNodeMime` so I didn't have to repeat the literal string multiple times, which decreases the potential for mistakes and typos and turns them into a compile-time error instead.
* Added `TreeModel::mimeTypes` to return the mime types supported by the tree model, for now it's just the "RadialGM/TreeNode" custom mime that is currently pointer based.
* Added `TreeModel::mimeData` to serialize tree nodes for drag and drop operations. 
    - It cannot do any IPC transferring of the data because it is purely pointer based for now.
    - I guard against drag operations originating outside the process by writing the application process id to the data stream and checking it later during the drop processing.
    - This can later be changed to just serialize the proto into bytes, but that requires some extra work I didn't want to do yet. For example, it will need to do some file transferring as well for certain resources like the sound file of a sound resource. I am not too sure how interested people would be in this proposed feature yet.
    - I sort the indices from lowest to highest row number so that I can make certain assumptions when processing a drop operation. For example, one of the things I like to assume is that other nodes removed from the same parent have effectively decreased the index of the current row we are removing. This also allows me to create new names for the nodes during a drag copy operation in a consecutive order.
* Added `TreeModel::dropMimeData` so the tree model can accept drop operations.
    - `ExtractSubrange` is used to remove the node from its parent's `child` repeated pointer field. I used this because it seemed to work but also the documentation says it releases ownership without destroying the item, which is what was intended.
    - `MoveAction` is the trickier one because it requires adjusting the insert and remove rows based on what rows we are dragging. This is even more complicated considering the fact that I chose to allow non-contiguous selections in the tree.
    - `CopyAction` is handled by doing a copy of the proto, not removing the previous nodes, and inserting the new nodes with a unique name based on their type. Later this will need to duplicate files on disk for certain resources, like the sound data file for a sound.
    - The insertion of the moved or copied nodes is done by appending it at the end of the new parent's `child` field. I then swap it into place since `RepeatedPtrField` has no built-in way of inserting items anywhere other than the end.

@EnigmaBot EnigmaBot released this Nov 13, 2018

Assets 6
Missing emake Crash Fix (#48)

Make keyword API a noop if emake not connected and look for emake in a folder named "enigma-dev" next to the executable.

@EnigmaBot EnigmaBot released this Nov 13, 2018

Assets 6
Resource Renaming Fix (#46)

* Removed the lambda that listens to `QAbstractItemModel::dataChanged` signal of `treeModel` to update the subwindow title for opened editors.
* Changed the `BaseEditor::dataChanged` slot to update the subwindow title.
* Changed `MainWindow::openSubWindow` to set the subwindow title directly on the editor widget that is used to create the subwindow. This stops the subwindow title from overriding the one set in the `BaseEditor::dataChanged` slot.
* Changed `TreeModel::setData` to compare the old and new name and short-circuit without firing any signals if they are the same.
* Added a `ResourceRenamed` signal to `TreeModel` that has the same signature as the signal emitted by `BaseEditor`.
* Changed `ResourceModelMap::ResourceRenamed` slot to compare the old and new name and short-circuit if they are the same or if there was no entry for a resource under the old name. Also made it remove the entry under the old name instead of setting it to a `nullptr` which should be safer and keep the map from growing unnecessarily large.
* Connected the `treeModel` to `resMap` so the latter is informed of when resources are renamed directly from the tree via an edit trigger. This fixes a crash that occurs when attempting to open the editor of a resource after just having renamed it in the tree.
* Connected the `treeModel` to `res` in `MainWindow::openSubWindow` so `res` knows when the resource is renamed from the tree. This ensures the subwindow title is updated when the resource is renamed from the tree.
* Changed `ProtoModel` constructor to forward its `dataChanged` signal that provides the old value as the `QAbstractItemModel` signal by the same name which doesn't. This ensures that components, like ImmediateMapper, that listen for the old signal will still receive the signal even if they don't care about the optional parameter.

@EnigmaBot EnigmaBot released this Nov 12, 2018

Assets 6
Fix Crash When Adding Tree Node (#47)

Use the correct row index when inserting a node into the tree which is one less than the child size since the child has already been added to the parent.

@EnigmaBot EnigmaBot released this Nov 8, 2018

Assets 6
Fix Crash When Opening Unknown Resources (#45)

Change the logic for opening a subwindow to not insert a tree node into the subwindows map unless there's a registered factory for the tree node's type case and a new subwindow is in fact created.

@EnigmaBot EnigmaBot released this Nov 5, 2018

Assets 6
Fix Tree Model Crashes for Missing Previews (#44)

Use no icon for sprites without subimages, missing sprite/background images, and objects with no sprites.

@EnigmaBot EnigmaBot released this Nov 5, 2018

Assets 6
Fix for Unknown Resource Conversion to Sprites (#43)

Don't allocate oneof fields not already set. This prevents conversion of unknown resources to sprites with a 0 id.