taisei/src/menu/difficultyselect.c
Andrei Alexeyev 8490576810
Premultiplied alpha (#133)
* WIP premultiplied alpha

* WIP color API rework (doesn't build yet; lots of things left to convert)

* convert everything remaining to new Color api except stage*_event.c files

* convert the stages to new Color api. builds & runs now; still many rendering errors

* fix the bullet shader for premultiplied alpha

* fix masterspark, graphs and stage 1 fog clouds

* fix marisa_b and most of spellcards

* Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD

* fix a segfault in stage 6

undo accidental earlier change

* fix text_hud.frag.glsl

* fix scuttle bg and remaining stage3 BLEND_ADDs

* fix marisa laser opacity

* hacky fix for myon

The old implementation relied on alpha being stored inside p->color. In
premul alpha this doesn’t work and functions like color_set_opacity
can’t solve this i think.

So I tried messing around with it until it looked somewhat similar.

* fix marisa_b stars

* remove color_set_opacity i overlooked

* more plrmode blending changes

* fixup additive blending in stage 1

* various premultiplied alpha fixups for bosses and enemies

* stage 2 premul alpha fixups

* stage 4 premul alpha fixups

* stage 5 premul alpha fixups

* stage 6 premul alpha fixups

* make lasers also use the PMA blend mode

* remove PFLAG_DRAWADD and PFLAG_DRAWSUB

* fix remaining PMA issues in menus

* lame extraspell bg workaround

* fix item alpha

* make marisaA lasers look somewhat like in master

* fix marisaA bomb background fadeout

* fixup various r_color4 calls

* fix myon

* remove dead code

* fix use of BLEND_ADD in player death effect

* fix myon shot trails (broken on master as well)

* fix myon shot fade-in

* extend the sprite shaders custom parameter to a vec4

* fix youmuB stuff and make it look somewhat better.

the code looks even worse though.
2018-07-23 20:07:59 +03:00

92 lines
2.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (c) 2011-2018, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2018, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "difficulty.h"
#include "difficultyselect.h"
#include "options.h"
#include "common.h"
#include "global.h"
#include "video.h"
// FIXME: put this into the menu struct somehow (drawdata is a bad system)
static Color diff_color;
void set_difficulty(MenuData *m, void *d) {
progress.game_settings.difficulty = (Difficulty)(uintptr_t)d;
}
void update_difficulty_menu(MenuData *menu) {
menu->drawdata[0] += (menu->cursor-menu->drawdata[0])*0.1;
for(int i = 0; i < menu->ecount; ++i) {
menu->entries[i].drawdata += 0.2 * (30*(i == menu->cursor) - menu->entries[i].drawdata);
}
color_approach(&diff_color, difficulty_color(menu->cursor + D_Easy), 0.1);
}
void create_difficulty_menu(MenuData *m) {
create_menu(m);
m->draw = draw_difficulty_menu;
m->logic = update_difficulty_menu;
m->transition = TransMenuDark;
m->flags = MF_Transient | MF_Abortable;
add_menu_entry(m, "“All those bullets confuse me!”\nYou will be stuck here forever", set_difficulty, (void *)D_Easy);
add_menu_entry(m, "“So this isnt about shooting things?”\nSomewhat challenging", set_difficulty, (void *)D_Normal);
add_menu_entry(m, "“Why cant I beat this?”\nActually challenging", set_difficulty, (void *)D_Hard);
add_menu_entry(m, "“What is pain?”\nAsian mode", set_difficulty, (void *)D_Lunatic);
for(int i = 0; i < m->ecount; ++i) {
Difficulty d = (Difficulty)(uintptr_t)m->entries[i].arg;
if(d == progress.game_settings.difficulty) {
m->cursor = i;
break;
}
}
}
void draw_difficulty_menu(MenuData *menu) {
draw_options_menu_bg(menu);
draw_menu_title(menu, "Select Difficulty");
Color c = diff_color;
r_color(color_mul(&c, RGBA(0.07, 0.07, 0.07, 0.7)));
r_mat_push();
r_mat_translate(SCREEN_W/2+30 - 25*menu->drawdata[0], SCREEN_H/3 + 90*(0.7*menu->drawdata[0]),0);
r_mat_rotate_deg(4*menu->drawdata[0]-4,0,0,1);
r_mat_push();
r_mat_scale(SCREEN_W*1.5,120,1);
r_shader_standard_notex();
r_draw_quad();
r_mat_pop();
r_color3(1,1,1);
r_shader("text_default");
text_draw(menu->entries[menu->cursor].name, &(TextParams) {
.pos = { 40+35*menu->drawdata[0], -12 },
});
r_shader("sprite_default");
r_mat_pop();
for(int i = 0; i < menu->ecount; ++i) {
r_mat_push();
r_mat_translate(SCREEN_W/2 + SCREEN_W*sign((i&1)-0.5)*(i!=menu->cursor)*menu_fade(menu) - (int)menu->entries[i].drawdata+25*i-50, SCREEN_H/3 + 90*(i-0.3*menu->drawdata[0]),0);
r_color3(1,1,1);
draw_sprite_batched(0, 0, difficulty_sprite_name(D_Easy+i));
r_mat_pop();
}
r_shader_standard();
}