cdn
This commit is contained in:
@@ -349,7 +349,7 @@
|
||||
const row = Math.floor(frameIndex / cols);
|
||||
const bgX = -col * tw;
|
||||
const bgY = -row * th;
|
||||
const imgUrl = `${cdnBaseUrl}/downloads/${cdn}`;
|
||||
const imgUrl = `${cdnBaseUrl}/${cdn}`;
|
||||
|
||||
spritePreview.innerHTML = `
|
||||
<div style="width: ${tw}px; height: ${th}px;
|
||||
|
||||
@@ -14,7 +14,6 @@ public class ObjectEditModel : AdminPageModel
|
||||
{
|
||||
_db = db;
|
||||
_config = config;
|
||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
@@ -25,16 +24,26 @@ public class ObjectEditModel : AdminPageModel
|
||||
public List<DamageResistanceType> DamageTypes { 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 bool IsError { get; set; }
|
||||
|
||||
public async Task OnGetAsync(int? id)
|
||||
{
|
||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
||||
await LoadReferenceData();
|
||||
|
||||
|
||||
if (id.HasValue)
|
||||
{
|
||||
var obj = await _db.ObjectTemplates
|
||||
@@ -61,7 +70,6 @@ public class ObjectEditModel : AdminPageModel
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
||||
await LoadReferenceData();
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
@@ -170,17 +178,4 @@ public class ObjectEditModel : AdminPageModel
|
||||
if (!baseUrl.EndsWith("/downloads")) baseUrl += "/downloads";
|
||||
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];
|
||||
if (t && sheet && t.sid == sheet.id) {
|
||||
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`;
|
||||
} else if (t) {
|
||||
c.style.background = '#2d3748';
|
||||
@@ -387,7 +387,7 @@ function loadTilePalette() {
|
||||
for (let i = 0; i < total; i++) {
|
||||
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}"
|
||||
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>`;
|
||||
}
|
||||
document.getElementById('tilePalette').innerHTML = html;
|
||||
|
||||
@@ -14,7 +14,6 @@ public class RoomEditModel : AdminPageModel
|
||||
{
|
||||
_db = db;
|
||||
_config = config;
|
||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
@@ -23,7 +22,18 @@ public class RoomEditModel : AdminPageModel
|
||||
public List<TileMapSheet> TileSheets { 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 bool IsError { get; set; }
|
||||
@@ -137,17 +147,4 @@ public class RoomEditModel : AdminPageModel
|
||||
.OrderBy(o => o.Name)
|
||||
.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) {
|
||||
const col = 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`;
|
||||
} else if (data) {
|
||||
cell.style.background = '#2d3748';
|
||||
@@ -381,7 +381,7 @@ function loadSheet() {
|
||||
const col = i % sheet.cols;
|
||||
const row = Math.floor(i / sheet.cols);
|
||||
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>`;
|
||||
}
|
||||
document.getElementById('palette').innerHTML = html;
|
||||
@@ -406,7 +406,7 @@ function selectTile(frameIndex) {
|
||||
const row = Math.floor(frameIndex / sheet.cols);
|
||||
document.getElementById('selectedPreview').innerHTML = `
|
||||
<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;
|
||||
image-rendering: pixelated;"></div>
|
||||
`;
|
||||
|
||||
@@ -14,7 +14,6 @@ public class TileEditModel : AdminPageModel
|
||||
{
|
||||
_db = db;
|
||||
_config = config;
|
||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
@@ -22,14 +21,24 @@ public class TileEditModel : AdminPageModel
|
||||
|
||||
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 bool IsError { get; set; }
|
||||
|
||||
public async Task OnGetAsync(int? id)
|
||||
{
|
||||
|
||||
await LoadReferenceData();
|
||||
|
||||
if (id.HasValue)
|
||||
@@ -134,17 +143,4 @@ public class TileEditModel : AdminPageModel
|
||||
.OrderBy(s => s.Name)
|
||||
.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 "";
|
||||
|
||||
var baseUrl = _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "";
|
||||
if (!baseUrl.EndsWith("/downloads"))
|
||||
var baseUrl = _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "https://assets.aeternalisgames.com";
|
||||
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
baseUrl += "/downloads";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user