added chunithm version selector in admin settings

This commit is contained in:
Polaris
2024-08-20 16:49:01 -04:00
parent 552f737650
commit d6629a72eb
37 changed files with 614 additions and 107 deletions

View File

@ -1,11 +1,12 @@
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { getSupportedVersionNumber } from "@/lib/api";
import { artemis } from "@/lib/prisma";
export async function getCurrentAvatarParts() {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
@ -36,6 +37,7 @@ export async function updateAvatarParts(
avatarItem?: number,
) {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
@ -69,6 +71,7 @@ export async function updateAvatarParts(
export async function getAllAvatarParts(category: number) {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");

View File

@ -34,11 +34,10 @@ import { toast } from "../../ui/use-toast";
import { updateAvatarParts } from "./actions";
type chunithm_avatar = chuni_static_avatar;
const getAvatarTextureSrc = (id: number | undefined) => {
if (id === undefined) return "";
return `avatarAccessory/CHU_UI_Avatar_Tex_0${id}.png`;
}
};
type AvatarSelectionProps = {
avatarHeadSelectionData: {
@ -116,18 +115,18 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
}, []);
function onSubmit(data: z.infer<typeof FormSchema>) {
// Existing state
const unchangedHeadId = avatarHeadId;
const unchangedFaceId = avatarFaceId;
const unchangedBackId = avatarBackId;
const unchangedWearId = avatarWearId;
const unchangedItemId = avatarItemId;
const defaultHeadId = avatarHeadId;
const defaultFaceId = avatarFaceId;
const defaultBackId = avatarBackId;
const defaultWearId = avatarWearId;
const defaultItemId = avatarItemId;
// either change to the new body part id or fallback to the unchanged if nothing has changed
const newHeadId = data.AvatarHeadAccessory ?? unchangedHeadId;
const newFaceId = data.AvatarFaceAccessory ?? unchangedFaceId;
const newBackId = data.AvatarBackAccessory ?? unchangedBackId;
const newWearId = data.AvatarWearAccessory ?? unchangedWearId;
const newItemId = data.AvatarItemAccessory ?? unchangedItemId;
// either change to the new body part id or fallback to the default if nothing has changed
const newHeadId = data.AvatarHeadAccessory ?? defaultHeadId;
const newFaceId = data.AvatarFaceAccessory ?? defaultFaceId;
const newBackId = data.AvatarBackAccessory ?? defaultBackId;
const newWearId = data.AvatarWearAccessory ?? defaultWearId;
const newItemId = data.AvatarItemAccessory ?? defaultItemId;
updateAvatarParts(newHeadId, newFaceId, newBackId, newWearId, newItemId)
.then(() => {
@ -265,7 +264,7 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
name="AvatarHeadAccessory"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Avatar Head Item</FormLabel>
<FormLabel className="pb-2">Avatar Head Item</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>
@ -330,7 +329,7 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
name="AvatarFaceAccessory"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Avatar Face Item</FormLabel>
<FormLabel className="pb-2">Avatar Face Item</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>
@ -395,7 +394,7 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
name="AvatarItemAccessory"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Avatar Hand Item</FormLabel>
<FormLabel className="pb-2">Avatar Hand Item</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>
@ -460,7 +459,7 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
name="AvatarBackAccessory"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Avatar Back Item</FormLabel>
<FormLabel className="pb-2">Avatar Back Item</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>
@ -525,7 +524,7 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
name="AvatarWearAccessory"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Avatar Clothing Item</FormLabel>
<FormLabel className="pb-2">Avatar Clothing Item</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>

View File

@ -1,11 +1,12 @@
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { getSupportedVersionNumber } from "@/lib/api";
import { artemis } from "@/lib/prisma";
export async function getCurrentMapIcon() {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
@ -25,6 +26,7 @@ export async function getCurrentMapIcon() {
export async function updatePlayerMapIcon(mapIconId?: number) {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");

View File

@ -108,7 +108,7 @@ export const MapIconCustomization: FC<SystemVoiceSelectionProps> = ({
mapIconId: {
src: mapIconId
? getTexture(
form.watch("mapIconId"),
mapIconId, // Use mapIconId directly
`mapIcon/CHU_UI_MapIcon_${mapIconId.toString().padStart(8, "0")}.png`,
)
: `systemVoiceThumbnails/CHU_UI_SystemVoice_Default.png`,
@ -121,7 +121,11 @@ export const MapIconCustomization: FC<SystemVoiceSelectionProps> = ({
<div className="">
{Object.entries(MapIconTextures).map(([key, { src }]) => (
<div>
<img className="w-[100px]" src={src} alt={""} />
<img
className="w-[100px]"
src={MapIconTextures.mapIconId.src}
alt={mapIconId ? `Map Icon ${mapIconId}` : "Default Map Icon"}
/>{" "}
</div>
))}
</div>
@ -133,7 +137,7 @@ export const MapIconCustomization: FC<SystemVoiceSelectionProps> = ({
name="mapIconId"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Select Map Icon</FormLabel>
<FormLabel className="pb-2">Select Map Icon</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>

View File

@ -1,11 +1,12 @@
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { getSupportedVersionNumber } from "@/lib/api";
import { artemis } from "@/lib/prisma";
export async function getCurrentNameplate() {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
@ -25,6 +26,7 @@ export async function getCurrentNameplate() {
export async function updatePlayerNamePlate(nameplateId?: number) {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");

View File

@ -77,8 +77,8 @@ export const NameplateCustomization: FC<AvatarSelectionProps> = ({
}, []);
function onSubmit(data: z.infer<typeof FormSchema>) {
const unchangedNamePlateId = nameplateId;
const newNamePlateId = data.nameplateId ?? unchangedNamePlateId;
const defaultNamePlateId = nameplateId;
const newNamePlateId = data.nameplateId ?? defaultNamePlateId;
updatePlayerNamePlate(newNamePlateId).then(() => {
setNameplateId(newNamePlateId);
@ -136,7 +136,7 @@ export const NameplateCustomization: FC<AvatarSelectionProps> = ({
name="nameplateId"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Select Nameplate</FormLabel>
<FormLabel className="pb-2">Select Nameplate</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>

View File

@ -1,11 +1,12 @@
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { getSupportedVersionNumber } from "@/lib/api";
import { artemis } from "@/lib/prisma";
export async function getCurrentSystemVoice() {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
@ -25,6 +26,7 @@ export async function getCurrentSystemVoice() {
export async function updatePlayerSystemVoiceId(voiceId: number) {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
@ -63,7 +65,7 @@ export async function updatePlayerSystemVoiceId(voiceId: number) {
console.log(updatePlayerNameplate);
return updatePlayerNameplate;
return unlockedSystemVoices;
} catch (error) {
console.error("Error updating nameplate:", error);
throw error;

View File

@ -143,7 +143,7 @@ export const SystemVoiceCustomization: FC<SystemVoiceSelectionProps> = ({
name="PlayerSystemVoice"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Select System Voice</FormLabel>
<FormLabel className="pb-2">Select System Voice</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>

View File

@ -1,11 +1,12 @@
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { getSupportedVersionNumber } from "@/lib/api";
import { artemis } from "@/lib/prisma";
export async function getCurrentTrophies() {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
@ -25,6 +26,7 @@ export async function getCurrentTrophies() {
export async function updatePlayerTrophy(trophyId: number) {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");

View File

@ -76,8 +76,8 @@ export const TrophyCustomization: FC<AvatarSelectionProps> = ({
}, []);
function onSubmit(data: z.infer<typeof FormSchema>) {
const unchangedNamePlateId = trophyID;
const newNamePlateId = data.trophies ?? unchangedNamePlateId;
const defaultNamePlateId = trophyID;
const newNamePlateId = data.trophies ?? defaultNamePlateId;
updatePlayerTrophy(newNamePlateId).then(() => {
setTrophyId(newNamePlateId);
@ -112,7 +112,7 @@ export const TrophyCustomization: FC<AvatarSelectionProps> = ({
name="trophies"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Select Trophy</FormLabel>
<FormLabel className="pb-2">Select Trophy</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>

View File

@ -7,6 +7,7 @@ const NAV_ITEMS = [
{ href: "/admin/home", label: "Home" },
{ href: "/admin/unlock", label: "Unlock User" },
{ href: "/admin/extraction", label: "Extract Game Files" },
{ href: "/admin/gameversions", label: "Edit Game Version" },
];
const AdminSubNavigation = () => {

View File

@ -1,10 +1,11 @@
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { getSupportedVersionNumber } from "@/lib/api";
import { artemis } from "@/lib/prisma";
export async function getUserRatingBaseHotList() {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");

View File

@ -1,10 +1,11 @@
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { getSupportedVersionNumber } from "@/lib/api";
import { artemis } from "@/lib/prisma";
export async function getUserRatingBaseList() {
const { user } = await getAuth();
const supportedVersionNumber = await getSupportedVersionNumber();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");