diff --git a/.gitignore b/.gitignore index 24623e9..a16a38a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store /config.js +/nbproject/private/ \ No newline at end of file diff --git a/database_functions.php b/database_functions.php new file mode 100644 index 0000000..b0dae1c --- /dev/null +++ b/database_functions.php @@ -0,0 +1,19 @@ +getMessage(); +} + + diff --git a/js/app/constants.js b/js/app/constants.js index 532678a..c1bfb76 100644 --- a/js/app/constants.js +++ b/js/app/constants.js @@ -379,7 +379,8 @@ THREAT_LIST : 24, CLOSEST_ENEMY : 25, CLOSEST_FRIENDLY : 26, - MAX : 27 + LOOT_RECIPIENTS : 27, + MAX : 28 }; /* SAI template constants */ diff --git a/js/app/sai.js b/js/app/sai.js index c281f87..ec2733b 100644 --- a/js/app/sai.js +++ b/js/app/sai.js @@ -277,7 +277,9 @@ return; } - $scope.SAIScript = "-- " + $scope.selectionText + "\n\n"; + // $scope.SAIScript = "-- " + $scope.selectionText + "\n\n"; + + $scope.SAIScript = "SQL = "; // non-smart_scripts data switch (Number($stateParams.sourceType)) { @@ -306,6 +308,22 @@ } else { $scope.SAIScript += "DELETE FROM `smart_scripts` WHERE (`source_type` = " + $stateParams.sourceType + " AND `entryorguid` = " + $stateParams.entryOrGuid + ");\n"; } + + + + $http({ + method : 'POST', + url : 'http://localhost/dev/sai_parser.php', + data : $scope.SAIScript, //forms user object + headers : {'Content-Type': 'application/x-www-form-urlencoded'} + }) + .success(function(data) { + + } + ); + + + // console.log($scope.SAIScript); }; /* [Function] disactive all tabs */ @@ -322,6 +340,8 @@ $scope.saiTabs.script = true; }; + + }); }()); diff --git a/js/app/sai/editor.js b/js/app/sai/editor.js index 6aae379..5d679d2 100644 --- a/js/app/sai/editor.js +++ b/js/app/sai/editor.js @@ -57,6 +57,9 @@ target_o : 0.0, comment : '' }; + + /* Default new row */ + /* Type check */ $scope.parseValues = function() { @@ -117,10 +120,100 @@ if (!$rootScope.isEntrySelected()) { return; } var newRow = angular.copy($scope.defaultNewRow); - newRow.id = rows.length; + + var lastrow = rows.length-1; + + try{ + if($scope.new_smart_scripts[lastrow].id >=0) + { + + newRow.id = $scope.new_smart_scripts[lastrow].id+1; + console.log(newRow.id); + } + else + { + newRow.id = rows.length+1; + console.log(newRow.id); + } + } + catch(err) + { + } + + + rows.splice(rows.length, 0, angular.copy(newRow)); }; + + /* [Function] Duplicate row to collection */ + $scope.duplicate = function(rows) { + if (!$rootScope.isEntrySelected() || $scope.selectedRow == -1) { return; } + + $scope.duplicateNewRow = { + entryorguid : parseInt($stateParams.entryOrGuid, 10), + source_type : parseInt($stateParams.sourceType, 10), + id : 0, + link : parseInt($scope.selected.link, 10), + event_type : parseInt($scope.selected.event_type, 10), + event_phase_mask : parseInt($scope.selected.event_phase_mask, 10), + event_chance : parseInt($scope.selected.event_chance, 10), + event_flags : parseInt($scope.selected.event_flags, 10), + event_param1 : parseInt($scope.selected.event_param1, 10), + event_param2 : parseInt($scope.selected.event_param2, 10), + event_param3 : parseInt($scope.selected.event_param3, 10), + event_param4 : parseInt($scope.selected.event_param4, 10), + action_type : parseInt($scope.selected.action_type, 10), + action_param1 : parseInt($scope.selected.action_param1, 10), + action_param2 : parseInt($scope.selected.action_param2, 10), + action_param3 : parseInt($scope.selected.action_param3, 10), + action_param4 : parseInt($scope.selected.action_param4, 10), + action_param5 : parseInt($scope.selected.action_param5, 10), + action_param6 : parseInt($scope.selected.action_param6, 10), + target_type : parseInt($scope.selected.target_type, 10), + target_param1 : parseInt($scope.selected.target_param1, 10), + target_param2 : parseInt($scope.selected.target_param2, 10), + target_param3 : parseInt($scope.selected.target_param3, 10), + target_x : parseFloat($scope.selected.target_x, 10), + target_y : parseFloat($scope.selected.target_y, 10), + target_z : parseFloat($scope.selected.target_z, 10), + target_o : parseFloat($scope.selected.target_o, 10), + comment : '' + }; + + var newRow = angular.copy($scope.duplicateNewRow); + + var lastrow = rows.length-1; + + try{ + if($scope.new_smart_scripts[lastrow].id >=0) + { + + newRow.id = $scope.new_smart_scripts[lastrow].id+1; + console.log(newRow.id); + } + else + { + newRow.id = rows.length+1; + console.log(newRow.id); + } + } + catch(err) + { + + } + + rows.splice(rows.length, 0, angular.copy(newRow)); + }; + + /* [Function] Reload Page */ + $scope.Reload = function() { + window.location.reload(); + }; + + $scope.SaveToDatabase = function() { + $scope.generateSAIScript(); + }; /* [Function] Get string by target_type */ $scope.getStringByTargetType = function(smartScript) { diff --git a/js/app/sai/labels.js b/js/app/sai/labels.js index 26347cd..d6db831 100644 --- a/js/app/sai/labels.js +++ b/js/app/sai/labels.js @@ -286,6 +286,7 @@ app.saiLabels.target_type.name[24] = "THREAT_LIST"; app.saiLabels.target_type.name[25] = "CLOSEST_ENEMY"; app.saiLabels.target_type.name[26] = "CLOSEST_FRIENDLY"; + app.saiLabels.target_type.name[27] = "LOOT_RECIPIENTS"; /* ACTION TOOLTIPS */ app.saiLabels.action_type.tooltip[0] = "No action type is specified. Do not use because it will cause errors on start-up."; @@ -499,6 +500,7 @@ app.saiLabels.target_type.tooltip[24] = "Targets the entire threatlist of the creature"; app.saiLabels.target_type.tooltip[25] = "Takes the closest unfriendly unit (both creatures and players) within a given distance. If second parameter is set to 1, it will only target nearby friendly players"; app.saiLabels.target_type.tooltip[26] = "Takes the closest friendly unit (both creatures and players) within a given distance. If second parameter is set to 1, it will only target nearby friendly players"; + app.saiLabels.target_type.tooltip[27] = "All tagging players"; /* ACTION PARAM1 NAMES */ app.saiLabels.action_type.param1[1] = "GroupId"; diff --git a/js/app/text.js b/js/app/text.js new file mode 100644 index 0000000..9fbcb4e --- /dev/null +++ b/js/app/text.js @@ -0,0 +1,90 @@ +/*jslint browser: true, eqeq: true, white: true, plusplus: true */ +/*global angular, console, alert*/ + +(function () { + 'use strict'; + + var app = angular.module('keira2'); + + app.controller("LootController", function ($scope, $rootScope, $stateParams) { + + /* At start we have no row selected */ + $scope.selectedRow = -1; + + /* The item currently selected by the user (bound to the view) */ + $scope.selected = { + Entry : parseInt($stateParams.id, 10), + Item : 0, + Reference : 0, + Chance : 100, + QuestRequired : 0, + LootMode : 1, + GroupId : 0, + MinCount : 1, + MaxCount : 1, + Comment : '' + }; + + /* Type check */ + $scope.parseValues = function() { + + $scope.selected.Item = parseInt($scope.selected.Item, 10); + $scope.selected.Reference = parseInt($scope.selected.Reference, 10); + $scope.selected.Chance = parseFloat($scope.selected.Chance, 10); + $scope.selected.QuestRequired = parseInt($scope.selected.QuestRequired, 10); + $scope.selected.LootMode = parseInt($scope.selected.LootMode, 10); + $scope.selected.GroupId = parseInt($scope.selected.GroupId, 10); + $scope.selected.MinCount = parseInt($scope.selected.MinCount, 10); + $scope.selected.MaxCount = parseInt($scope.selected.MaxCount, 10); + }; + + /* Select a row from collection */ + $scope.selectRow = function(rows, index) { + $scope.selectedRow = index; + $scope.selected = angular.copy(rows[index]); + }; + + /* Edit selected row */ + $scope.editSelectedRowOf = function(rows, primaryKey2) { + if (!$scope.isEntrySelected()) { return; } + var i; + $scope.parseValues(); + + // check primaryKey2 uniqueness + for (i = 0; i < rows.length; i++) { + if ( (rows[i][primaryKey2] == $scope.selected[primaryKey2]) && (i !== $scope.selectedRow) ) { + alert("Duplicate row with `" + primaryKey2 + "` = " + $scope.selected[primaryKey2]); + return; + } + } + + rows.splice($scope.selectedRow, 1, angular.copy($scope.selected)); + }; + + /* Delete selected row from collection */ + $scope.deleteSelectedRowFrom = function(rows) { + if (!$rootScope.isEntrySelected()) { return; } + + rows.splice($scope.selectedRow, 1); + }; + + /* Add selected row to collection */ + $scope.addRowTo = function(rows, primaryKey2) { + if (!$rootScope.isEntrySelected()) { return; } + var i; + $scope.parseValues(); + + // check primaryKey2 uniqueness + for (i = 0; i < rows.length; i++) { + if (rows[i][primaryKey2] == $scope.selected[primaryKey2]) { + alert("Duplicate row with `" + primaryKey2 + "` = " + $scope.selected[primaryKey2]); + return; + } + } + + rows.splice(0, 0, angular.copy($scope.selected)); + }; + + }); + +}()); diff --git a/partials/sai.html b/partials/sai.html index c67e817..959fffb 100644 --- a/partials/sai.html +++ b/partials/sai.html @@ -8,7 +8,7 @@
-
+
diff --git a/partials/sai/creature-text.html b/partials/sai/creature-text.html new file mode 100644 index 0000000..bc84b86 --- /dev/null +++ b/partials/sai/creature-text.html @@ -0,0 +1,109 @@ + +
+
+
+
+
+ Item +
+ +
+ +
+
+
+
+ Reference + +
+
+ Chance + +
+
+
+
+
+
+ QuestRequired + +
+
+ LootMode +
+ +
+ +
+
+
+
+ GroupId + +
+
+
+
+
+
+ MinCount + +
+
+ MaxCount + +
+
+ Comment + +
+
+
+
+
+
+
+ + + +
+
+
+ +
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ItemReferenceChanceQuestRequiredLootModeGroupIdMinCountMaxCountComment
{{ loot.Reference == 0 ? loot.Item : "" }}{{ loot.Reference != 0 ? loot.Item : "" }}{{ loot.Reference }}{{ loot.Chance }}{{ loot.QuestRequired }}{{ loot.LootMode }}{{ loot.GroupId }}{{ loot.MinCount }}{{ loot.MaxCount }}{{ loot.Comment }}
+
+
diff --git a/partials/sai/editor.html b/partials/sai/editor.html index dfdd828..7681514 100644 --- a/partials/sai/editor.html +++ b/partials/sai/editor.html @@ -250,9 +250,12 @@
-
+
+ + +
diff --git a/sai_parser.php b/sai_parser.php new file mode 100644 index 0000000..3eefa8f --- /dev/null +++ b/sai_parser.php @@ -0,0 +1,20 @@ +exec($_POST["SQL_"]); + + +} + + + + + +