From 3224d1737391ad1b79dfe393dcce3ba1fe5d6699 Mon Sep 17 00:00:00 2001 From: Quinta <0pietroquintavalle0@gmail.com> Date: Sun, 18 Aug 2024 18:37:15 +0200 Subject: [PATCH] little stuff --- app/info/page.tsx | 33 +++++++++++++++-------------- components/GlyphGenerator.tsx | 40 ++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/app/info/page.tsx b/app/info/page.tsx index ba89664..103de9f 100644 --- a/app/info/page.tsx +++ b/app/info/page.tsx @@ -2,9 +2,7 @@ import React from 'react'; import Header from '@/components/Header'; import { Separator } from "@/components/ui/separator"; -import {Button} from "@/components/ui/button"; -import {router} from "next/client"; -import {useRouter} from "next/navigation"; +import { useRouter } from "next/navigation"; import { ChevronsLeft } from 'lucide-react'; import Link from "next/link"; @@ -13,17 +11,20 @@ export default function InfoPage() { return (
-
+
- router.back()} className="mr-4" /> -

No Man's Sky Portal Address Tool - Information

+ router.back()} + className="mr-4 cursor-pointer text-gray-500 hover:bg-gray-200 rounded-full transition-colors duration-200" + size={24} + /> +

No Man's Sky Portal Address Tool - Information

-

What is this tool?

-

This tool helps No Man's Sky players generate, translate, and share portal addresses. It consists - of three main features:

-
    +

    What is this tool?

    +

    This tool helps No Man's Sky players generate, translate, and share portal addresses. It consists of three main features:

    +
    • Generator: Create random portal addresses or input your own.
    • Translator: Convert between hexadecimal addresses and glyph symbols.
    • Gallery: Share and discover interesting locations with the community.
    • @@ -31,32 +32,32 @@ export default function InfoPage() {
-

How to use the Generator

+

How to use the Generator

The generator allows you to create random portal addresses or input your own. You can also add descriptions, tags, and images to share in the gallery.

-

How to use the Translator

+

How to use the Translator

The translator converts between hexadecimal addresses and glyph symbols. You can toggle between translating from hex to glyphs or from glyphs to hex.

-

What is the Gallery?

+

What is the Gallery?

The gallery is a community-driven feature where players can share interesting locations they've discovered. You can add your own discoveries or browse and vote on others' finds.

-

Why do I need to enter my NMS friendship code?

+

Why do I need to enter my NMS friendship code?

Your NMS friendship code is used to identify your contributions to the gallery and to prevent duplicate voting. It's not shared publicly and is only used within the tool.

-

How Portal Addresses Work

+

How Portal Addresses Work

In No Man's Sky, portal addresses consist of 12 glyphs chosen from a set of 16 possible glyphs. The first glyph represents the planetary index, the next two the solar system index, followed by one for the planet index, and the remaining eight for specific X, Y, and Z coordinates within that system. By inputting a specific sequence of glyphs, players can teleport to corresponding locations across the vast game world.

-

Special Thanks

+

Special Thanks

Thanks to the The Game Hub and the No Man's Sky community for their support and inspiration.

And to Rask Rex for helping me with lots of feedback!

diff --git a/components/GlyphGenerator.tsx b/components/GlyphGenerator.tsx index bd66e10..a01879a 100644 --- a/components/GlyphGenerator.tsx +++ b/components/GlyphGenerator.tsx @@ -173,6 +173,7 @@ const GlyphGenerator = () => { const [user, setUser] = useState(null); const [gallery, setGallery] = useState([]); const [selectedGalaxy, setSelectedGalaxy] = useState(galaxies[0]); + const [editingGalaxy, setEditingGalaxy] = useState(galaxies[0]); const getGlyphImagePath = (glyph: string) => { const basePath = process.env.NODE_ENV === 'production' ? '/nmsportal' : ''; @@ -415,23 +416,27 @@ const GlyphGenerator = () => { return; } setEditingItem(item); - setDescription(item.description); - setTags(item.tags.join(', ')); - setImages(item.images.map(url => ({ url, file: null }))); + setDescription(item.description || ''); + setTags(item.tags?.join(', ') || ''); + setImages(item.images?.map(url => ({ url, file: null })) || []); + setEditingGalaxy(item.galaxy || galaxies[0]); }; + const saveEdit = async () => { try { const updatedItem = { ...editingItem, description: description, tags: tags.split(',').map(tag => tag.trim()), - images: images.map(img => img.url) + images: images.map(img => img.url), + galaxy: editingGalaxy === "Not Specified" ? null : editingGalaxy }; await update(ref(database, `gallery/${editingItem?.id}`), updatedItem); setEditingItem(null); setDescription(''); setTags(''); setImages([]); + setEditingGalaxy(galaxies[0]); showAlertMessage('Address details updated successfully.'); loadGallery(); // Reload the gallery to reflect the changes } catch (error) { @@ -441,8 +446,21 @@ const GlyphGenerator = () => { }; const handleFriendshipCodeInput = async (e: React.ChangeEvent) => { - const code = e.target.value; + let code = e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ''); + + code = code.replace(/-/g, ''); + + if (code.length > 4) { + code = code.slice(0, 4) + '-' + code.slice(4); + } + if (code.length > 9) { + code = code.slice(0, 9) + '-' + code.slice(9); + } + + code = code.slice(0, 14); + setFriendshipCode(code); + if (user) { try { await set(ref(database, `users/${user.uid}/friendshipCode`), code); @@ -642,6 +660,18 @@ const GlyphGenerator = () => { placeholder="Edit tags, separated by commas" className="mb-2" /> +