Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.

New Features + Under development features + DB connection for Localhost #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
/config.js
/nbproject/private/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing NewLine or CR/LF at EOF.

19 changes: 19 additions & 0 deletions database_functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

try {

$host = "";
$dbname = "";
$user = "";
$pass = "";

# MySQL with PDO_MYSQL
$REMOTE_DB = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);


}
catch(PDOException $e) {
echo $e->getMessage();
}


3 changes: 2 additions & 1 deletion js/app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@
THREAT_LIST : 24,
CLOSEST_ENEMY : 25,
CLOSEST_FRIENDLY : 26,
MAX : 27
LOOT_RECIPIENTS : 27,
MAX : 28
};

/* SAI template constants */
Expand Down
22 changes: 21 additions & 1 deletion js/app/sai.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 */
Expand All @@ -322,6 +340,8 @@
$scope.saiTabs.script = true;
};



});

}());
95 changes: 94 additions & 1 deletion js/app/sai/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
target_o : 0.0,
comment : ''
};

/* Default new row */


/* Type check */
$scope.parseValues = function() {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions js/app/sai/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down Expand 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";
Expand Down
90 changes: 90 additions & 0 deletions js/app/text.js
Original file line number Diff line number Diff line change
@@ -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));
};

});

}());
2 changes: 1 addition & 1 deletion partials/sai.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</uib-tab>
<uib-tab heading="SmartAI Editor" active="saiTabs.editor">
<div ng-include="'partials/sai/editor.html'" ng-controller="SmartAIEditorController"></div>
</uib-tab>
</uib-tab>
<uib-tab heading="SQL Script" ng-click="generateSAIScript()" active="saiTabs.script">
<div ng-include="'partials/sai/sql-script.html'"></div>
</uib-tab>
Expand Down
Loading