level editor functional

This commit is contained in:
Hash Borgir
2023-09-10 20:02:58 -06:00
parent 59c8e1ecfe
commit 974de24f6f
8 changed files with 144 additions and 163 deletions

View File

@@ -42,6 +42,70 @@
*/
function writeToTsvFile($tsvFileName, $db = DB_FILE) {
$tsvFilePath = $_SESSION['path'] . '/' . $tsvFileName . '.txt';
// Open the file for writing
$fileHandle = fopen($tsvFilePath, 'w');
if (!$fileHandle) {
return "Error opening file for writing.";
}
// Query to select all rows from the treasureclassex table
$query = "SELECT * FROM $tsvFileName";
// Execute the query
$result = $db->query($query);
if (!$result) {
fclose($fileHandle);
return "Error executing query.";
}
// Write the column headers to the file
$columnNames = [];
for ($i = 0; $i < $result->numColumns(); $i++) {
$columnNames[] = $result->columnName($i);
}
fwrite($fileHandle, implode("\t", $columnNames) . "\n");
// Write the rows to the file
while ($row = $result->fetchArray(SQLITE3_NUM)) {
fwrite($fileHandle, implode("\t", $row) . "\n");
}
// Close the file
fclose($fileHandle);
return "Successfully updated and written to TSV file!";
}
function exportSQLiteTableToTSV($tablename) {
$bin = "../bin/sqlite3.exe";
$dbfile = DB_FILE;
// Generate the output file name based on the tablename
$outputFile = $_SESSION['path'] . $tablename . ".txt";
// Build the command to export the SQLite table to a TSV file
$command = sprintf(
'%s %s ".mode tabs" ".headers on" "SELECT * FROM %s;" > "%s"',
escapeshellarg($bin),
escapeshellarg($dbfile),
escapeshellarg($tablename),
escapeshellarg($outputFile)
);
// Execute the command
$commandOutput = shell_exec($command);
if ($commandOutput) {
return "Error: $commandOutput";
} else {
return "Table exported successfully!";
}
}
/**
* @param $var
* @return void

View File

@@ -1,11 +1,8 @@
<div class="Doc-container">
<div class="container">
<h2>Generate Documentation</h2>
<div class="row">
<div style="text-align: center; padding: 10px; margin-top: 20px;" class="col Doc-UniqueItems">
<div class="container">
<div class="form-group row">
@@ -30,9 +27,12 @@
<div class="col Doc-Runes"><?php require_once "Runewords.php"; ?></div>
<div class="col Doc-Misc"><?php require_once "Misc.php"; ?></div>
<div class="col Doc-Armor"><?php require_once "Armor.php"; ?></div>
<div class="col Doc-Weapons"><?php require_once "Weapons.php"; ?></div>
<div class="col Doc-Weapons"><?php require_once "Weapons.php"; ?></div>
</div>
<h2>Various Editors</h2>
<div class="row">
<div class="col Doc-TCEX"><?php require_once "TC.php"; ?></div>
<div class="col Doc-Levels"><?php require_once "Levels.php"; ?></div>
</div>
</div>

59
src/tabs/Levels.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
/*
Copyright (C) 2021 Hash Borgir
This file is part of D2Modder
Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* This software must not be used for commercial purposes
* without my consent. Any sales or commercial use are prohibited
* without my express knowledge and consent.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY!
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
?>
<div style="text-align: center; margin-top: 20px;">
<div class="container">
<div class="form-group row">
<div class="" style="text-align: center; margin: 0 auto;">
<a style="margin-top: 60px; text-align: center;" target="_blank" href="/LevelsEditor.php" class="">
<div style="height: 100px;">
<img style="height: 100px;" class="img-fluid" src="/img/loading_.gif">
</div>
</a>
</div>
</div>
<!-- <a class="btn btn-warning" target="_blank" href="/genDocs.php?cmd=genDocCube">Generate</a> -->
<p>Levels.txt Vis/Warp Editor</p>
</div>
</div>