cdn
This commit is contained in:
@@ -349,7 +349,7 @@
|
|||||||
const row = Math.floor(frameIndex / cols);
|
const row = Math.floor(frameIndex / cols);
|
||||||
const bgX = -col * tw;
|
const bgX = -col * tw;
|
||||||
const bgY = -row * th;
|
const bgY = -row * th;
|
||||||
const imgUrl = `${cdnBaseUrl}/downloads/${cdn}`;
|
const imgUrl = `${cdnBaseUrl}/${cdn}`;
|
||||||
|
|
||||||
spritePreview.innerHTML = `
|
spritePreview.innerHTML = `
|
||||||
<div style="width: ${tw}px; height: ${th}px;
|
<div style="width: ${tw}px; height: ${th}px;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public class ObjectEditModel : AdminPageModel
|
|||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_config = config;
|
_config = config;
|
||||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BindProperty]
|
[BindProperty]
|
||||||
@@ -25,16 +24,26 @@ public class ObjectEditModel : AdminPageModel
|
|||||||
public List<DamageResistanceType> DamageTypes { get; set; } = new();
|
public List<DamageResistanceType> DamageTypes { get; set; } = new();
|
||||||
public List<string> CdnImages { get; set; } = new();
|
public List<string> CdnImages { get; set; } = new();
|
||||||
|
|
||||||
public string CdnBaseUrl;// => _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "";
|
public string CdnBaseUrl => NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"]);
|
||||||
|
|
||||||
|
private string NormalizeCdnBaseUrl(string? baseUrl)
|
||||||
|
{
|
||||||
|
baseUrl = string.IsNullOrWhiteSpace(baseUrl)
|
||||||
|
? "https://assets.aeternalisgames.com"
|
||||||
|
: baseUrl;
|
||||||
|
baseUrl = baseUrl.TrimEnd('/');
|
||||||
|
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
||||||
|
baseUrl += "/downloads";
|
||||||
|
return baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public string? Message { get; set; }
|
public string? Message { get; set; }
|
||||||
public bool IsError { get; set; }
|
public bool IsError { get; set; }
|
||||||
|
|
||||||
public async Task OnGetAsync(int? id)
|
public async Task OnGetAsync(int? id)
|
||||||
{
|
{
|
||||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
|
||||||
await LoadReferenceData();
|
await LoadReferenceData();
|
||||||
|
|
||||||
if (id.HasValue)
|
if (id.HasValue)
|
||||||
{
|
{
|
||||||
var obj = await _db.ObjectTemplates
|
var obj = await _db.ObjectTemplates
|
||||||
@@ -61,7 +70,6 @@ public class ObjectEditModel : AdminPageModel
|
|||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync()
|
public async Task<IActionResult> OnPostAsync()
|
||||||
{
|
{
|
||||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
|
||||||
await LoadReferenceData();
|
await LoadReferenceData();
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
@@ -170,17 +178,4 @@ public class ObjectEditModel : AdminPageModel
|
|||||||
if (!baseUrl.EndsWith("/downloads")) baseUrl += "/downloads";
|
if (!baseUrl.EndsWith("/downloads")) baseUrl += "/downloads";
|
||||||
return $"{baseUrl}/{path.TrimStart('/')}";
|
return $"{baseUrl}/{path.TrimStart('/')}";
|
||||||
}
|
}
|
||||||
private static string NormalizeCdnBaseUrl(string? baseUrl)
|
|
||||||
{
|
|
||||||
baseUrl = string.IsNullOrWhiteSpace(baseUrl)
|
|
||||||
? "https://assets.aeternalisgames.com"
|
|
||||||
: baseUrl;
|
|
||||||
|
|
||||||
baseUrl = baseUrl.TrimEnd('/');
|
|
||||||
|
|
||||||
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
|
||||||
baseUrl += "/downloads";
|
|
||||||
|
|
||||||
return baseUrl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ function render(x, y) {
|
|||||||
const t = tileData[k];
|
const t = tileData[k];
|
||||||
if (t && sheet && t.sid == sheet.id) {
|
if (t && sheet && t.sid == sheet.id) {
|
||||||
const col = t.f % sheet.cols, row = Math.floor(t.f / sheet.cols);
|
const col = t.f % sheet.cols, row = Math.floor(t.f / sheet.cols);
|
||||||
c.style.background = `url('${cdnBase}/downloads/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat`;
|
c.style.background = `url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat`;
|
||||||
c.style.backgroundSize = `${sheet.sw}px ${sheet.sh}px`;
|
c.style.backgroundSize = `${sheet.sw}px ${sheet.sh}px`;
|
||||||
} else if (t) {
|
} else if (t) {
|
||||||
c.style.background = '#2d3748';
|
c.style.background = '#2d3748';
|
||||||
@@ -387,7 +387,7 @@ function loadTilePalette() {
|
|||||||
for (let i = 0; i < total; i++) {
|
for (let i = 0; i < total; i++) {
|
||||||
const col = i % sheet.cols, row = Math.floor(i / sheet.cols);
|
const col = i % sheet.cols, row = Math.floor(i / sheet.cols);
|
||||||
html += `<div class="palette-item" data-type="tile" data-sid="${sheet.id}" data-f="${i}" title="Frame ${i}"
|
html += `<div class="palette-item" data-type="tile" data-sid="${sheet.id}" data-f="${i}" title="Frame ${i}"
|
||||||
style="background:url('${cdnBase}/downloads/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat; background-size:${sheet.sw}px ${sheet.sh}px;"
|
style="background:url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat; background-size:${sheet.sw}px ${sheet.sh}px;"
|
||||||
onclick="selectPaletteItem(this)"></div>`;
|
onclick="selectPaletteItem(this)"></div>`;
|
||||||
}
|
}
|
||||||
document.getElementById('tilePalette').innerHTML = html;
|
document.getElementById('tilePalette').innerHTML = html;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public class RoomEditModel : AdminPageModel
|
|||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_config = config;
|
_config = config;
|
||||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BindProperty]
|
[BindProperty]
|
||||||
@@ -23,7 +22,18 @@ public class RoomEditModel : AdminPageModel
|
|||||||
public List<TileMapSheet> TileSheets { get; set; } = new();
|
public List<TileMapSheet> TileSheets { get; set; } = new();
|
||||||
public List<ObjectTemplate> Objects { get; set; } = new();
|
public List<ObjectTemplate> Objects { get; set; } = new();
|
||||||
|
|
||||||
public string CdnBaseUrl;// => _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "";
|
public string CdnBaseUrl => NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"]);
|
||||||
|
|
||||||
|
private string NormalizeCdnBaseUrl(string? baseUrl)
|
||||||
|
{
|
||||||
|
baseUrl = string.IsNullOrWhiteSpace(baseUrl)
|
||||||
|
? "https://assets.aeternalisgames.com"
|
||||||
|
: baseUrl;
|
||||||
|
baseUrl = baseUrl.TrimEnd('/');
|
||||||
|
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
||||||
|
baseUrl += "/downloads";
|
||||||
|
return baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public string? Message { get; set; }
|
public string? Message { get; set; }
|
||||||
public bool IsError { get; set; }
|
public bool IsError { get; set; }
|
||||||
@@ -137,17 +147,4 @@ public class RoomEditModel : AdminPageModel
|
|||||||
.OrderBy(o => o.Name)
|
.OrderBy(o => o.Name)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
private static string NormalizeCdnBaseUrl(string? baseUrl)
|
|
||||||
{
|
|
||||||
baseUrl = string.IsNullOrWhiteSpace(baseUrl)
|
|
||||||
? "https://assets.aeternalisgames.com"
|
|
||||||
: baseUrl;
|
|
||||||
|
|
||||||
baseUrl = baseUrl.TrimEnd('/');
|
|
||||||
|
|
||||||
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
|
||||||
baseUrl += "/downloads";
|
|
||||||
|
|
||||||
return baseUrl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ function renderCell(x, y) {
|
|||||||
if (data && sheet && data.sheetId == sheet.id) {
|
if (data && sheet && data.sheetId == sheet.id) {
|
||||||
const col = data.frameIndex % sheet.cols;
|
const col = data.frameIndex % sheet.cols;
|
||||||
const row = Math.floor(data.frameIndex / sheet.cols);
|
const row = Math.floor(data.frameIndex / sheet.cols);
|
||||||
cell.style.background = `url('${cdnBase}/downloads/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat`;
|
cell.style.background = `url('${cdnBase}/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat`;
|
||||||
cell.style.backgroundSize = `${sheet.sw}px ${sheet.sh}px`;
|
cell.style.backgroundSize = `${sheet.sw}px ${sheet.sh}px`;
|
||||||
} else if (data) {
|
} else if (data) {
|
||||||
cell.style.background = '#2d3748';
|
cell.style.background = '#2d3748';
|
||||||
@@ -381,7 +381,7 @@ function loadSheet() {
|
|||||||
const col = i % sheet.cols;
|
const col = i % sheet.cols;
|
||||||
const row = Math.floor(i / sheet.cols);
|
const row = Math.floor(i / sheet.cols);
|
||||||
html += `<div class="palette-tile" data-frame="${i}" onclick="selectTile(${i})"
|
html += `<div class="palette-tile" data-frame="${i}" onclick="selectTile(${i})"
|
||||||
style="background: url('${cdnBase}/downloads/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat;
|
style="background: url('${cdnBase}/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat;
|
||||||
background-size: ${sheet.sw}px ${sheet.sh}px;"></div>`;
|
background-size: ${sheet.sw}px ${sheet.sh}px;"></div>`;
|
||||||
}
|
}
|
||||||
document.getElementById('palette').innerHTML = html;
|
document.getElementById('palette').innerHTML = html;
|
||||||
@@ -406,7 +406,7 @@ function selectTile(frameIndex) {
|
|||||||
const row = Math.floor(frameIndex / sheet.cols);
|
const row = Math.floor(frameIndex / sheet.cols);
|
||||||
document.getElementById('selectedPreview').innerHTML = `
|
document.getElementById('selectedPreview').innerHTML = `
|
||||||
<div style="width: ${sheet.tw}px; height: ${sheet.th}px;
|
<div style="width: ${sheet.tw}px; height: ${sheet.th}px;
|
||||||
background: url('${cdnBase}/downloads/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat;
|
background: url('${cdnBase}/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat;
|
||||||
background-size: ${sheet.sw}px ${sheet.sh}px;
|
background-size: ${sheet.sw}px ${sheet.sh}px;
|
||||||
image-rendering: pixelated;"></div>
|
image-rendering: pixelated;"></div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public class TileEditModel : AdminPageModel
|
|||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_config = config;
|
_config = config;
|
||||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BindProperty]
|
[BindProperty]
|
||||||
@@ -22,14 +21,24 @@ public class TileEditModel : AdminPageModel
|
|||||||
|
|
||||||
public List<TileMapSheet> TileSheets { get; set; } = new();
|
public List<TileMapSheet> TileSheets { get; set; } = new();
|
||||||
|
|
||||||
public string CdnBaseUrl;// => _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "";
|
public string CdnBaseUrl => NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"]);
|
||||||
|
|
||||||
|
private string NormalizeCdnBaseUrl(string? baseUrl)
|
||||||
|
{
|
||||||
|
baseUrl = string.IsNullOrWhiteSpace(baseUrl)
|
||||||
|
? "https://assets.aeternalisgames.com"
|
||||||
|
: baseUrl;
|
||||||
|
baseUrl = baseUrl.TrimEnd('/');
|
||||||
|
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
||||||
|
baseUrl += "/downloads";
|
||||||
|
return baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public string? Message { get; set; }
|
public string? Message { get; set; }
|
||||||
public bool IsError { get; set; }
|
public bool IsError { get; set; }
|
||||||
|
|
||||||
public async Task OnGetAsync(int? id)
|
public async Task OnGetAsync(int? id)
|
||||||
{
|
{
|
||||||
|
|
||||||
await LoadReferenceData();
|
await LoadReferenceData();
|
||||||
|
|
||||||
if (id.HasValue)
|
if (id.HasValue)
|
||||||
@@ -134,17 +143,4 @@ public class TileEditModel : AdminPageModel
|
|||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
private static string NormalizeCdnBaseUrl(string? baseUrl)
|
|
||||||
{
|
|
||||||
baseUrl = string.IsNullOrWhiteSpace(baseUrl)
|
|
||||||
? "https://assets.aeternalisgames.com"
|
|
||||||
: baseUrl;
|
|
||||||
|
|
||||||
baseUrl = baseUrl.TrimEnd('/');
|
|
||||||
|
|
||||||
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
|
||||||
baseUrl += "/downloads";
|
|
||||||
|
|
||||||
return baseUrl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ public class TilesModel : AdminPageModel
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path)) return "";
|
if (string.IsNullOrEmpty(path)) return "";
|
||||||
|
|
||||||
var baseUrl = _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "";
|
var baseUrl = _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "https://assets.aeternalisgames.com";
|
||||||
if (!baseUrl.EndsWith("/downloads"))
|
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
baseUrl += "/downloads";
|
baseUrl += "/downloads";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user