src/ui.c

Fri, 01 Aug 2025 17:58:28 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 01 Aug 2025 17:58:28 +0200
changeset 236
7ad67e547266
parent 235
e9540bfa5803
permissions
-rw-r--r--

update player texture

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * Copyright 2025 Mike Becker. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. 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 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 HOLDER 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.
 */

#define ASC_UI_IMPLEMENTATION
#include "ascension/ui.h"

#include "ascension/context.h"
#include "ascension/scene.h"

#include <math.h>

void asc_ui_add_node(AscSceneNode *node) {
    asc_scene_add_node(&asc_active_window->ui, node);
}

void asc_ui_scale(float scale) {
    asc_active_window->ui_scale = scale;
}

float asc_ui_get_scale(void) {
    return asc_active_window->ui_scale;
}

float asc_ui_scale_auto(void) {
    const asc_vec2u res = asc_window_display_resolution();
    float scale = roundf((float)res.height / 108.f) / 10.f;
    asc_ui_scale(scale);
    return scale;
}

mercurial